fix: tolerate closed curl handles in AsyncCurl cleanup - #807
Open
dokson wants to merge 1 commit into
Open
Conversation
A Curl handle closed while still tracked by AsyncCurl left its entries in the internal maps and nulled the underlying pointer, so a later AsyncCurl.close raised TypeError. Skip the C-level removal for already closed handles, always drop the bookkeeping entries in _pop_future, and cancel the pending future when removal fails.
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 #802. Closing a
Curlhandle whileAsyncCurlstill tracks it (e.g.add_handlecancelled by a timeout, thencurl.close()) left its entries in the internal maps with a nulled pointer, so a laterAsyncCurl.close()raisedTypeError: initializer for ctype 'void *' must be a cdata pointer, not NoneType.close()and_pop_future()now skip the C-level removal for already-closed handles,_pop_future()drops the bookkeeping entries even whencurl_multi_remove_handlefails (the race in the follow-up comment), and the popped future is cancelled before re-raising so no task is left hanging. Both regression tests fail with theTypeErroron current main.Checklist