-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix connection pooling #473
Fix connection pooling #473
Conversation
The invariant should be: a transport is either in the free list (_conns) or in the active list (_acquired). This fixes a bug that put every newly created connection in both lists
Issues aio-libs#253 and aio-libs#254 implemented a `_conns` key evince logic in the function that actually **adds** items to `_conns` Issue aio-libs#406 tweaked this logic even more, making early and eviction of reusable items in the pool possible. Here we put the key eviction logic where it belongs: in the method that **removes** items from the `_conns` pool.
Nice found! But can we have any test to prove that this wouldn't be broken in future? |
Previously, on error we would call the `.close()` method on the response object. This actually releases the connection instead of closing it, thus making it available again in the pool. By passing the `force=True` arg, we make sure the connection is not put back in the pool.
I did add a specific test and fixed a few existing bous ones, let's see what the buildbots say |
One branch in the `_get` logic did not drop the key as expected.
I am testing this in staging now and solves all the that came out upgrading from 0.14.x to 0.17.2
|
+1, this fixes certain requests consistently timing out in my application starting with aiohttp 0.17.0. |
+1, those ServerDisconnectedError exceptions are very annoying |
Thanks! i'll test changes and then will do new bug fix release |
You are welcome! I've tested this on staging for a week now and it works all right |
Fixes weirdness introduced in #254 and #254 and later in #406 .
Supersedes #471
See commit messages for more details