-
-
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
"Unclosed connection" warning, but close method was awaited #5277
Comments
This problem will be fixed by aiohttp 4.0 only, sorry. |
uhm when will aiohttp 4.0 be released? |
Any update on this? I'm suffering this problem as well. Attempting to close the session before exiting the context manager doesn't help, and I get other problems if I try to keep the session around longer: Is there some workaround I can use to squelch the constant warnings and/or when is aiohttp 4.0 coming? |
I suspect there is a better solution than creating a new session every time, though I'm not familiar with the issue.
Ignore them? https://docs.python.org/3/library/warnings.html#warnings.filterwarnings |
This bug is specifically that using one session per request does not solve the problem. My earlier reply indicates other problems if you go the other way and keep a session for multiple requests. They're logs, not warnings, AFAIK so not easy to ignore. I found another reference yesterday to someone trying to filter them like that and failing. FWIW, I think I've found that if I call close() on the response itself, it will alleviate the problem. i.e.:
|
Ah no, the code should create a warning, but it also calls the exception handler (which is what you see). So, just ignore that in the exception handler:
|
Sure, but that's a huge hammer (hack), it may conflict with other default handler overrides, and you lose the reporting of actual problems in that case. What I wanted was a way to appease whatever is getting upset at otherwise totally proper behavior. I believe closing the response does that, without sacrificing the reporting of actual problems. |
There is only 1 exception handler for a loop.
Well, you could try play around with some kind of context manager that only suppresses these in particular places in your code.
The proper solution is apparently in master, but can't be backported to 3.x. You asked for a workaround to suppress the warnings, so that's what I gave you. If there was a clean, precise way to fix it in 3.x, it would already have been implemented in aiohttp. |
That's not good ((( 📛 |
🐞 Describe the bug
Despite context manager using, after some amount of new sessions, getting warning of Unclosed connection
💡 To Reproduce
just run script above
💡 Expected behavior
I understand that creating a new session each time is not a good idea, still, I'm not expecting any warnings in this case
📋 Logs/tracebacks
One more thing is that there may be situations when there are no warnings or their amount changes from time to time.
📋 Your version of the Python
📋 Your version of the aiohttp/yarl/multidict distributions
📋 Additional context
client
The text was updated successfully, but these errors were encountered: