Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7e25c26

Browse filesBrowse files
committed
document some ways to use cancel()
1 parent dac2cef commit 7e25c26
Copy full SHA for 7e25c26

File tree

1 file changed

+8
-0
lines changed
Filter options

1 file changed

+8
-0
lines changed

‎Doc/library/asyncio-task.rst

Copy file name to clipboardExpand all lines: Doc/library/asyncio-task.rst
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ and reliable way to wait for all tasks in the group to finish.
359359
:meth:`cancel` is idempotent and may be called after the task group has
360360
already exited.
361361

362+
Ways to use :meth:`cancel`:
363+
* call it from the task group body based on some condition or
364+
event
365+
* pass the task group instance to child tasks via :meth:`create_task`,
366+
allowing a child task to conditionally cancel the entire entire group
367+
* pass the task group instance or bound :meth:`cancel` method to some
368+
other task *before* opening the task group, allowing remote cancellation
369+
362370
.. versionadded:: next
363371

364372
Example::

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.