mirror of https://github.com/python/cpython
19 lines
952 B
ReStructuredText
19 lines
952 B
ReStructuredText
Improved behavior of :class:`asyncio.TaskGroup` when an external cancellation
|
|
collides with an internal cancellation. For example, when two task groups
|
|
are nested and both experience an exception in a child task simultaneously,
|
|
it was possible that the outer task group would misbehave, because
|
|
its internal cancellation was swallowed by the inner task group.
|
|
|
|
In the case where a task group is cancelled externally and also must
|
|
raise an :exc:`ExceptionGroup`, it will now call the parent task's
|
|
:meth:`~asyncio.Task.cancel` method. This ensures that a
|
|
:exc:`asyncio.CancelledError` will be raised at the next
|
|
:keyword:`await`, so the cancellation is not lost.
|
|
|
|
An added benefit of these changes is that task groups now preserve the
|
|
cancellation count (:meth:`asyncio.Task.cancelling`).
|
|
|
|
In order to handle some corner cases, :meth:`asyncio.Task.uncancel` may now
|
|
reset the undocumented ``_must_cancel`` flag when the cancellation count
|
|
reaches zero.
|