> ## Documentation Index
> Fetch the complete documentation index at: https://aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancellation

`function` **Cancellation.new**

<pre language="python">
  `def Cancellation.new() -> cancellation.Token`
</pre>

A token nothing cancels but you. Bind a process to it to keep it out of Ctrl+C and stop it yourself, with `cancel()` on the token or `interrupt()`, `terminate()` and `kill()` on the handle.

`property` **Cancellation.root**

<pre language="python">
  `Cancellation.root: cancellation.Token`
</pre>

The run's root token. The operating system cancels it on Ctrl+C or SIGTERM; `root.cancel()` does the same from AXL. Every process spawned without an explicit `cancellation =` is bound to it and stops when it is cancelled. The task itself keeps running: read `root.cancelled` on a tick to end on your own terms, or let your waits return as the children stop. A task still running at the deadline is ended with exit 130 (143 for SIGTERM), its post-task hooks, `ctx.defer` callbacks and bookend intact.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.