8000 gh-90908: Document asyncio.Task.cancelling() and asyncio.Task.uncancel() by ambv · Pull Request #95253 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-90908: Document asyncio.Task.cancelling() and asyncio.Task.uncancel() #95253

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

Merged
merged 12 commits into from
Oct 1, 2022
Prev Previous commit
Next Next commit
Apply suggestions from Guido's code review
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
  • Loading branch information
ambv and gvanrossum authored Jul 27, 2022
commit 4a6a2fe901b714c5ceba97242ae655d22b76fa76
8 changes: 3 additions & 5 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,10 @@ perform clean-up logic. In case :exc:`asyncio.CancelledError`
is explicitly caught, it should generally be propagated when
clean-up is complete. Most code can safely ignore :exc:`asyncio.CancelledError`.

asyncio components that enable structured concurrency, like
The asyncio components that enable structured concurrency, like
:class:`asyncio.TaskGroup` and the :func:`asyncio.timeout` context manager,
are implemented using cancellation internally and might misbehave if
a coroutine swallows :exc:`asyncio.CancelledError`. In particular,
they might :func:`uncancel <asyncio.Task.uncancel>` a task to properly
isolate cancelling only a given structured block within the task's body.
a coroutine swallows :exc:`asyncio.CancelledError`.

.. _taskgroups:

Expand Down Expand Up @@ -1188,7 +1186,7 @@ Task Object

Note that if this number is greater than zero but the Task is
still executing, :meth:`cancelled` will still return ``False``.
It's because this number can be lowered by calling :meth:`uncancel`,
This is because this number can be lowered by calling :meth:`uncancel`,
which can lead to the task not being cancelled after all if the
cancellation requests go down to zero.

Expand Down
0