You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
asyncio.TaskGroup swallows cancellations coming from outside of it #155433
Proposed fix - add else branch: if uncancel() leaves requests pending, cancellation was not ours, so we need to propogate it
ifself._parent_cancel_requested:
# If this flag is set we *must* call uncancel().ifself._parent_task.uncancel() ==0:
# If there are no pending cancellations left,# don't propagate CancelledError.propagate_cancellation_error=Noneelse:
propagate_cancellation_error=exceptions.CancelledError()
Activity
kumaraditya303 commentedon Aug 20, 2026
I think there might be issues if the parent task is already cancelling though I haven't verified it, do you want to look into that?
deadlovelll commentedon Aug 20, 2026
Yeah, i'll take a look today
deadlovelll commentedon Aug 20, 2026
I just checked this, and if i understand you well - no, there is no issues:
On main this code prints "swallowed, still pending: 1", in the fix branch it raises
CancelledErrorgh-155433: Fix TaskGroup losing outside cancellation after cancel() (#…
Drop test for pythongh-155433
[3.15] gh-155433: Fix TaskGroup losing outside cancellation after can…