Repository navigation
gh-160429: Ignore ConnectionResetError from shutdown() when closing proactor sockets - #160909
Open
devanshc777 wants to merge 1 commit into
Open
devanshc777 wants to merge 1 commit into
devanshc777 wants to merge 1 commit into
Conversation
…sing proactor sockets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows, if the peer resets the connection after sending FIN,
sock.shutdown(SHUT_RDWR)in_ProactorBasePipeTransport._call_connection_lost()raisesConnectionResetError(WinError 10054). The rest of the cleanup is skipped: the socket stays open, the transport is never detached from its server, andServer.wait_closed()never returns.The connection is already gone at that point, so the reset is ignored, the same way
_loop_reading()and_loop_writing()already treatConnectionResetErroras a normal end of the connection. Othershutdown()errors propagate as before.Reproduced with real sockets on Windows 11 against a debug build of main: the server writes a response, the client half-closes without reading it, then closes, which sends a RST. Without the fix, 10 of 10 runs left the socket open (the debug build reports it as an unclosed-socket
ResourceWarning) andwait_closed()hung; with the fix, 10 of 10 cleaned up. The added test uses a mocked socket, liketest_call_connection_lost.test_asynciopasses on the same build.gh-160600 was an earlier draft for this issue, closed by its author before review.