Handling AsyncConnectionPool._attempt_to_acquire_connection returning false? #855
Replies: 1 comment
|
The pool implementation has changed substantially since the code this question refers to, and the current design does have the missing wake-up/reassignment point. There is no longer an That method iterates all queued requests and, for each origin, either:
Each There is also a deliberate race fallback: if a connection looked available during assignment but So the fairness question today is mostly about queue ordering/policy rather than “only one waiter ever gets a connection.” The current |
Uh oh!
There was an error while loading. Please reload this page.
I was reading the code for
AsyncConnectionPoolto see if there were ways to tweak httpx so I can recover faster from network blips from another service I am calling. Looking at the_attempt_to_acquire_connectionimplementation and I see it will bail out under various conditions but there doesn't seem to be anything that will retry getting a connection for a given status.It looks like the lock might protect some cases but its hard to understand if this is sufficient. If it is why have the waiting/ordering check?
From my reading of the code if multiple
_requestever get queued up with no connection only one will get a connection and the rest will get PoolTimeouts.There seems like there is a similar issue with _max_connections being hit.
I can try to open a PR for this though I don't really have a good repro for any bug. I would the correct behavior here would be to trust the fairness of the
_pool_lockif we can. It also seems like there needs to be some other async event that fires that retries_requestswhere_attempt_to_acquire_connectionreturned false though.All reactions