File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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).
You can’t perform that action at this time.
0 commit comments