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
asyncio.gather(..., return_exceptions=True) swallows cancellation #76865
Labels
3.7
only security fixes
3.8
only security fixes
topic-asyncio
type-bug
An unexpected behavior, bug, or error
Comments
Proof: ================ import asyncio
async def test():
while True:
print('sleeping 1')
await asyncio.gather(asyncio.sleep(1), return_exceptions=True)
async def amain():
print('creating task')
qwe = asyncio.Task(test())
print('sleeping 2')
await asyncio.sleep(2)
print('cancelling task')
qwe.cancel()
print('waiting task for completion')
try:
await qwe
except Exception as e:
print('task complete: %r', e)
loop = asyncio.get_event_loop()
loop.run_until_complete(amain()) ================ This program will never complete. This case should be either fixed, or documented. |
See also bpo-26923, but I think this problem is different. |
Thanks for reporting this. Agree, this is a bug and makes it hard (if not impossible) to use gather. I've created a PR to address the issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.7
only security fixes
3.8
only security fixes
topic-asyncio
type-bug
An unexpected behavior, bug, or error
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: