PyDocs

Nav

Networking and Interprocess Communication

TaskGroup.cancel

asyncio

method of TaskGroup · Added in 3.15 (source) not WASI
  • TaskGroup.cancel()
Cancel the task group

`cancel()` will be called on any tasks in the group that aren't yet
done, as well as the parent (body) of the group.  This will cause
the task group context manager to exit *without*
`asyncio.CancelledError` being raised.

If `cancel()` is called before entering the task group, the group
will be cancelled upon entry.  This is useful for patterns where
one piece of code passes an unused TaskGroup instance to another in
order to have the ability to cancel anything run within the group.

`cancel()` is idempotent and may be called after the task group has
already exited.
0 Examples
No examples for asyncio/TaskGroup.cancel.
See Also
No see-alsos for asyncio/TaskGroup.cancel
0 Notes
No notes for TaskGroup.cancel