classCancelToken#

class CancelToken#

Thread-safe flag that stops a long-running operation.

Pass it as cancel= and call cancel from another thread. The operation raises Cancelled the next time it checks the token.

cancel() → None#

Request cancellation. This cannot be undone.

property cancelled: bool#

Whether cancellation has been requested.

check() → None#

Stop here if cancellation has been requested.

Raises:

Cancelled – Cancellation has been requested.