reader, writer = await asyncio.open_connection(host, port)
discard_task = asyncio.create_task(discard_stream(reader))
try:
- remaining = frames_remaining
- while remaining > 0:
- frames = min(chunk_frames, remaining)
- writer.write(frame * frames)
+ # The server may close the connection before we have written the
+ # whole stream. This shows up notably on Alma Linux 8: under
+ # concurrent load its small default TCP buffers let the flow
+ # control between us and named wedge, named then hits its idle
+ # timeout and resets the connection mid-write, and drain() raises
+ # ConnectionResetError. That is fine -- the connection being torn
+ # down is acceptable and the only thing this test asserts is that
+ # named survives the flood, which the query below checks -- so
+ # tolerate the server closing the connection early.
+ with contextlib.suppress(ConnectionResetError):
+ remaining = frames_remaining
+ while remaining > 0:
+ frames = min(chunk_frames, remaining)
+ writer.write(frame * frames)
+ await writer.drain()
+ remaining -= frames
+
+ writer.write_eof()
await writer.drain()
- remaining -= frames
-
- writer.write_eof()
- await writer.drain()
writer.close()
with contextlib.suppress(ConnectionError, OSError):