Skip to main content
function Token.cancel
def Token.cancel() -> None
Cancel this token and every token derived from it, and wake every wait(). Every process bound to one of them starts its stop sequence. Cancelling ctx.cancellation.root ends the task as Ctrl+C would. function Token.child
def Token.child() -> cancellation.Token
A token cancelled whenever this one is. Cancelling the child never affects this token. Bind a piece of work to a child to be able to stop just that piece: sub = ctx.cancellation.root.child(). function Token.wait
def Token.wait(
*,
timeout_ms: None | int = None
) -> bool
Block until this token is cancelled, or timeout_ms passes. Returns True when it was cancelled, False on the timeout. property Token.cancelled
Token.cancelled: bool
Whether this token has been cancelled, by cancel() on it or on an ancestor, or by the operating system for the root. What a loop checks on its tick.