-
-
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
ClientSession CancelledError in old versions #1991
Labels
Comments
New script that will iterate until a CancelledError is raised. Useful to check which versions are affected: import sys
import logging
import asyncio
import aiohttp
import concurrent
logger = logging.getLogger(__name__)
class Service:
def __init__(self):
self.session = aiohttp.ClientSession()
async def do(self, timeout):
async with self.session.get('https://api.github.com/events', timeout=timeout) as resp:
logger.warning("%s, %s", timeout, resp.status)
async def view():
service1 = Service()
service2 = Service()
try:
await service1.do(0.0000001)
except asyncio.TimeoutError:
logger.exception("Caught TimeoutError")
try:
await service2.do(20)
except concurrent.futures.CancelledError:
logger.exception("GOT CANCELLED")
sys.exit(0)
async def iterate_view():
for x in range(100):
await view()
loop = asyncio.get_event_loop()
loop.run_until_complete(iterate_view()) |
this was bug in old versions |
I can find commit at the moment |
If you remember the issue or the commit let me know. Good to know it was identified and fixed. Thanks! |
There was issue, but I can not find it. Will look later |
Amazing, thanks a lot! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
DISCLAIMER: This is related with older versions of aiohttp. 2.1.0 seems not to be affected but all previous are.
Hi, I've been playing a bit due to a bug we had in production and finally found out why. It's related with
ClientSession
timeouts and how we capture exceptions. This is a small snippet reproducing what we have:Now this is the output I receive:
Note that the
TimeoutError
exception is being caught but apparentlyCancelledError
is also raised in the second call??I was able to reproduce this with the following versions of aiohttp:
Now, I couldn't reproduce this in 2.1.0 but going through the release notes, I haven't seen anything related. I'm trying to understand if this was fixed somewhere or was just fixed as a side effect of another issue? or maybe the issue is still there but much harder to reproduce?
Thanks
The text was updated successfully, but these errors were encountered: