Conversation
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
One retry hole still looks open here: _closed is set before _close_connections(closing). If one of those connection closes raises, a second aclose() returns immediately and that cleanup is never retried. Could the flag move after _close_connections(), or otherwise keep those pending closes retryable?
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.
Summary
Fixes #1115.
A response close interrupted by cancellation used to leave both byte-stream wrappers marked closed before their cleanup completed. Any later close then returned immediately, leaving the pool request and its HTTP/1.1 connection counted as active. This is the connection leak reported in encode/httpx#3782.
The wrappers now serialize close calls and set
_closedonly after the inner close and pool bookkeeping succeed. An interrupted close therefore remains retryable. The generated synchronous implementations are kept in step with the async sources, as required by the repository.The regression test interrupts the network close with
CancelledError, confirms the pool is still occupied, retriesresponse.aclose(), and verifies that the request and connection are removed. The test fails againstmasterwith one active request and connection.Checklist
Validation:
scripts/unasync.py --check