Cancelled tasks not being taken into account in connection pool's aclose #2342
Unanswered
hvmptydvmpty
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
hi, i've a question about httpx/httpcore, specifically a
RuntimeErrorraised byhttpcore.AsyncConnectionPool.aclosemethod. i issue multiple GET requests to an API and if one of them fails i'd like to cancel any that are still in flight. when i cancel corresponding tasks (and even include them inasyncio.gathercall) I then get the exception (httpcore._async.connection_pool) becauserequests_still_in_flightisTrue. Could someone please suggest a solution that both cancels pending requests and cleanly closeshttpx.AsyncClientand the embedded connection pool? If there isn't one, perhapsrequests_still_in_flightcould be adjusted to include only requests that are not in cancelled (but undone) state, since closing connection pool will presumably close active TCP connection(s) and thereby follow the protocol?I checked discussions #2138 and #2093 and the difference is that I actually do call
.cancel()on all remaining tasks if one of them errors out, but still get exception.General idea of the code is like this
Beta Was this translation helpful? Give feedback.
All reactions