Closed romasku closed 2 months ago
@romasku can you reproduce this on master? I'm almost sure it should be fixed with aiohttp v4
Unfotunately, it is still reproducible on master:
$ python test.py
/usr/lib/python3.9/asyncio/sslproto.py:320: ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x7f96c350d880>
_warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
$ python -m pip show aiohttp
Name: aiohttp
Version: 4.0.0a1
AFAIK on master there is a fix for an issue in the client, while this issue is about a problem in the server part of the library, but maybe I am wrong.
Hello, Is there an update on this issue? We seem to be facing this issue too.
I think this is the issue that has a workaround for aiohttp 3.x is documented at: https://docs.aiohttp.org/en/stable/client_advanced.html?highlight=sleep#graceful-shutdown
Thanks for the reproducer @romasku, that was really helpful in figuring this out finally.
🐞 Describe the bug Server with ssl enabled do not closes
_SSLProtocolTransport
properly, which leads to ResourceWarning. This💡 To Reproduce
Run the following script (requires trustme package).
💡 Expected behavior
No warnings are generated.
📋 Logs/tracebacks
📋 Your version of the Python
📋 Your version of the aiohttp/yarl/multidict distributions
📋 Additional context
As I can see from source code, the reason is that
web_protocol.RequestHandler.connection_lost
is called whentransport
is still active because of keepalive. As a workaround, one can setkeepalive_timeout
to zero (it can be OK for tests):runner = web.AppRunner(app, keepalive_timeout=0)
.