Skip to content

Commit

Permalink
pythonGH-95289: Always call uncancel() when required
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Aug 1, 2022
1 parent c7e5bba commit 6cd25fc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Lib/asyncio/taskgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,22 @@ async def __aenter__(self):

async def __aexit__(self, et, exc, tb):
self._exiting = True
propagate_cancellation_error = None

if (exc is not None and
self._is_base_error(exc) and
self._base_error is None):
self._base_error = exc

if et is not None:
if et is exceptions.CancelledError:
if self._parent_cancel_requested and not self._parent_task.uncancel():
# Do nothing, i.e. swallow the error.
pass
else:
propagate_cancellation_error = exc
propagate_cancellation_error = \
exc if et is exceptions.CancelledError else None
if self._parent_cancel_requested:
# If this flag is set we *must* call uncancel().
if self._parent_task.uncancel() == 0:
# If there are no pending cancellations left,
# don't propagate CancelledError.
propagate_cancellation_error = None

if et is not None:
if not self._aborting:
# Our parent task is being cancelled:
#
Expand Down

0 comments on commit 6cd25fc

Please sign in to comment.