-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
wait_for raises CancelledError #114496
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
Comments
Can someone (doesn't have to be the OP) please supply an example that doesn't depend on an external library? From the traceback it looks like |
Using asyncio.timeout directly:
I think the conversion to TimeoutError is not done due to
cpython/Lib/asyncio/timeouts.py Lines 109 to 115 in 1e4f00e
Not using the c-module for asyncio to see who cancels gets me to async def try_connect(remote_host: str, event: Event) -> None:
nonlocal connected_stream
try:
stream = await asynclib.connect_tcp(remote_host, remote_port, local_address)
except OSError as exc:
oserrors.append(exc)
return
else:
if connected_stream is None:
connected_stream = stream
tg.cancel_scope.cancel()
else:
await stream.aclose()
finally:
event.set() anyio canceling via tg.cancel_scope.cancel() I may be wrong wrt. to cpython causing this. @gvanrossum Given the opportunity. We've had an argument about tulip/asyncio ~10 years ago. I disagreed, lack of experience/vision. You were right. |
I tried to look at this,
This downloads the tar file as a data stream and stores in the tar format. This example uses While looking at the documentation for
I am not too aware of the inner working of asyncio, thanks @commonism for explaining that. |
The problem we have is the |
AnyIO does uncancel the task when exiting cancelled cancel scopes (as of v4), so it shouldn't pose a problem. Could someone create a minimal reproducing example of the problem? I don't have a lot of bandwidth to dedicate to this. |
I still don't see a simple repro that doesn't use a 3rd party module. (Also, the code snippets presented as "repro" are incomplete, they lack the needed imports and the I may just close this issue for lack of information if the situation doesn't improve within a week. PS. @commonism I don't know who you are (or who you were 10 years ago) so I cannot comment on the disagreement we had then -- I have no idea what it was about. :-) |
Looks like the behavior is expected.
Seems no bug here. |
I agree with anyIO causing this. |
Bug report
Bug description:
Problem is, wait_for sometimes raises CancelledError instead of TimeoutError.
Had a look on recent changes and updated Lib/asyncio/timeouts.py with #113819 by @serhiy-storchaka which seemed similar.
I failed to do to reproduce with sleep only/without httpx.
As the exception raised is either TimeoutError or CancelledError, I consider this an cpython issue.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: