httpcore.AsyncConnectionPool poisoning due to asyncio.CancelledError
#1053
Unanswered
nikitagashkov
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.
-
Hello,
I’d like to report an issue we are encountering with the
httpx/httpcorestack.In a real-world scenario, our application (O) concurrently calls two downstream services (T1 and T2). We observed the following sequence:
httpx.PoolTimeout.httpx.PoolTimeouterrors.A simplified version of the real code looks like this:
Our hypothesis is that
t2_taskstarts execution but gets cancelled due to an exception int1_task. As a result, some connections may not be cleaned up properly, eventually exhausting the connection pool.I was able to reproduce what appears to be the same underlying issue with the following minimal example:
At this point, the pool reports one active connection even though there are no active or queued requests, and subsequent requests fail with
httpcore.PoolTimeout. This suggests that task cancellation duringpool.request()can leave the pool in an inconsistent state where connections are not properly released.Thank you for taking a look! Let me know if additional details or diagnostics would be helpful.
Beta Was this translation helpful? Give feedback.
All reactions