-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
bpo-40894: asyncio.gather() cancelled() always False #20686
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
base: main
Are you sure you want to change the base?
bpo-40894: asyncio.gather() cancelled() always False #20686
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Could you create a NEWS entry please? Simple one liner should suffice. |
@MaxwellDupre It's unlikely, we missed him: |
…ancel() was called beforehand
f03e3cf
to
9ed6260
Compare
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
@MaxwellDupre @arhadthedev Rebased and added news entry. Thx for the reminder! |
… connection and cancellation and handle exceptions more gracefully. This addresses the 1006 issue.
bpo-40894: asyncio.gather() cancelled() always False
It seems like the future subclass returned by asyncio.gather() (
_GatheringFuture
) can never return True for future.cancelled() even after it's cancel() has been invoked successfully (returning True) and an await on it actually raised a CancelledError. This is in contrast to the behavior of normal Futures and it seems generally to be classified as a minor bug by developers.This PR consists of a small and simple fix. So maybe this is a minor bug, whose fix has no backward-compatibility consequences. However, my understanding is that asyncio.gather() is scheduled for deprecation, so maybe changes in this area are on halt anyways!?
Summary
This PR enables
asyncio.gather().cancelled()
to returnTrue
by overriding_GatheringFuture.cancelled()
to returnTrue
when:_GatheringFuture.done()
is True._GatheringFuture
hasCancelledError
set as exception.https://bugs.python.org/issue40894