-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
bpo-32684: Fix gather to propagate cancel of itself with return_exceptions #7209
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
Conversation
@@ -599,6 +600,11 @@ def cancel(self): | |||
for child in self._children: | |||
if child.cancel(): | |||
ret = True | |||
if ret: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow why future cancellation should be propagated but if children are tasks nothing should be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://bugs.python.org/issue26923 and, specifically, Task.cancel()
: if the task is done/cancelled, we don't raise CancelledError
. Similarly for gather()
, if all of its tasks are already done, we don't raise it.
This seems to be a super rare edge case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thanks @1st1 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
GH-7222 is a backport of this pull request to the 3.7 branch. |
…tions (pythonGH-7209) (cherry picked from commit 863b674) Co-authored-by: Yury Selivanov <yury@magic.io>
Sorry, @1st1, I could not cleanly backport this to |
3.6 PR: #7224 |
https://bugs.python.org/issue32684