-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
ResourceWarning when accessing response content #4779
Comments
Is this a duplicate of #1115? |
#1115 is an old bug reported in 2016 and "fixed" (actually not fixed, just documented a workaround) in 2017. I didn't even look at bugs fixed that long before since I am using recent software and shouldn't be affected by bugs fixed several years ago. So the thing I reported with the reproducer may actually be a duplicate of #1115. That being said the issue I'm actually facing is getting these ResourceWarnings in the middle of a long-running program with many parallel workers (each of them creating its own ClientSession), long before the program finishes (and could do the |
Can be reproduced with a HEAD request, I checked, it's the same leak: import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession() as session:
async with session.head("https://github.com/") as r:
...
asyncio.run(main()) gives the same traceback that the one with the
|
Isn't that a cpython bug? The code in your traceback points to https://github.com/python/cpython/blob/main/Lib/asyncio/selector_events.py#L78 |
Owwww, this is known and documented: https://docs.aiohttp.org/en/stable/client_advanced.html#graceful-shutdown This is the underlying SSL protocol having to shutdown gracefully. aiohttp calls "close()" on it, but it won't immediatly close the underlying socket: it starts a shutdown procedure first, and close it later, sleeping a few milliseconds often suffice for the socket to actually be closed. |
Right, forgot all about that. Duplicate of #1925 which is fixed in (unreleased) v4. |
ResourceWarning when accessing response content
When trying to access the response content, aiohttp will always return a ResourceWarning:
Simple reproducer:
This script will output a ResourceWarning:
Environment:
Ubuntu 20.04
Python 3.8.2
Package versions (in a minimal venv with just aiohttp + dependencies installed):
The text was updated successfully, but these errors were encountered: