-
-
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
Graceful shutdown for client sessions #2039
Labels
Comments
Or maybe even a busy loop:
Really, anything but "just call |
5 tasks
Closed by #2045. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Long story short
We have a great guide for graceful shutdown of server connections. We need the same guide for client connections.
Expected behaviour
I except that when I pack everything into
async with
, I don't have to worry about closing underlying connections.Actual behaviour
Even the simplest client connection produces a
ResourceWarning
on exit. This was first reported in #1115.Steps to reproduce
When run, this produces a
ResourceWarning
. This is quite unexpected given that everything is wrapped inasync with
.Resolution
The resolution in #1115 was:
I'd really prefer another way to go about it, but apparently this can't be done.
In my own tests, I had to use
await asyncio.sleep(0.25)
. I also triedsleep(0.2)
, which failed approximately 1 out of 10 times.Do we really have to rely on this mechanic? Is it completely impossible to have an
await aiohttp.wait_closed()
call or similar? Maybe said function could internally just callawait asyncio.sleep(x)
, wherex
is found empirically through a comprehensive test.In any case, at least add this to the documentation. That is, please add a Graceful Shutdown guide for client connections (as is already done for server connections).
Your environment
Python 3.6.1. Aiohttp 2.2.0.
The text was updated successfully, but these errors were encountered: