Skip to content

Commit b5d9a8b

Browse files
authored
Update client.py
1 parent 7297a83 commit b5d9a8b

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎python_agent_harness/client.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,16 @@ def _shutdown_and_close(sock: _socket.socket) -> None:
882882
after, so a new socket could reuse the fd number before the
883883
reader observed the EOF. The grace sleep delays the fd release
884884
so the woken thread can observe the EOF on the old fd first.
885+
886+
On Windows, ``shutdown(SHUT_RDWR)`` on the client socket causes
887+
``WinError 10058`` on the server side when it tries to read,
888+
producing noisy BrokenPipeError tracebacks. Skipping shutdown
889+
and just closing the fd is sufficient — Windows ``close()``
890+
triggers a TCP RST that reliably wakes the blocked read.
885891
"""
886-
with contextlib.suppress(OSError):
887-
sock.shutdown(_socket.SHUT_RDWR)
892+
if sys.platform != "win32":
893+
with contextlib.suppress(OSError):
894+
sock.shutdown(_socket.SHUT_RDWR)
888895
if sys.platform == "darwin":
889896
# macOS only; on Linux shutdown() alone reliably wakes the
890897
# blocked recv (measured: <200ms unblock, no sleeps needed).

0 commit comments

Comments
 (0)