Repository navigation
Fix own_client so close() closes the client created internally - #284
Merged
Merged
Conversation
Contributor
Author
|
The only failed job is |
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.
Fixes #283
The
elsebranch of_RPClient.__init__creates its ownClientbut setsown_client = False, soclose()skipsself.__client.close()and the aiohttp session stays open until garbage collection warns about it. Set the flag toTruein that branch; a client passed viaclient=remains borrowed and is still not closed.Client.__setstate__also restores_session = None, because__getstate__removes it and unpickling left the attribute missing. Without this, the newly-enabledclose()path on an unpickled wrapper raisedAttributeError, and an unpickledClientalso failed on its firstsession()call.Regression tests:
tests/aio/test_batched_client.py::test_own_client_reflects_client_ownership(parametrized overBatchedRPClientandThreadedRPClient) assertsown_clientisTruefor an internally-created client andFalsefor an injected one. Both params fail ondevelopwithassert False is True.test_batched_rp_client_picklingnow checks the unpickled wrapper owns its client and thatclose()succeeds.Full suite: 418 passed, 2 pre-existing network/port failures (
tests/_internal/aio/test_aio_http.py::test_no_retry_on_ok_request—OSError: [Errno 48] Address already in use;tests/_internal/test_http.py::test_no_auth_request—requests.exceptions.ConnectionError). Both also fail on the unmodified base.