Skip to content

Commit

Permalink
Add what's new entry
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Apr 4, 2024
1 parent 48c6dda commit 1e20728
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,28 @@ asyncio
never awaited).
(Contributed by Arthur Tacca and Jason Zhang in :gh:`115957`.)

* Improved behavior of :class:`asyncio.TaskGroup` when an outside 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 hang, because its internal
cancellation was swallowed by the inner task group.

In the case where a task group is cancelled from the outside and also must
raise an :exc:`ExceptionGroup`, it will now call the parent task's
:meth:`~asyncio.Task.cancel` method. This allows a :keyword:`try` /
:keyword:`except* <except_star>` surrounding the task group to handle
the exceptions in the ``ExceptionGroup`` without losing the cancellation.
The :exc:`asyncio.CancelledError` will be raised at the next
:keyword:`await` (which may be implied at the end of a surrounding
:keyword:`async with` block).

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.

base64
------

Expand Down

0 comments on commit 1e20728

Please sign in to comment.