Skip to content

Utilities

Cancelling long calls.

utils.cancel

Cancelling long calls: spy missions and kingdom scans take a cancel event.

A call that takes cancel: threading.Event looks at it between requests, never during one. A request in flight is left to end with its own reply or timeout, so its waiter is never abandoned and its reply cannot be taken by the next request for that command (see Connection.request); cancelling is noticed within one request's timeout. Setting the event is the whole API: one event can cancel many calls, for example at shutdown.

Functions:

Name Description
sleep_unless_cancelled

Sleep seconds, waking as soon as cancel is set; whether it is set.

sleep_unless_cancelled

sleep_unless_cancelled(seconds: float, cancel: Event | None) -> bool

Sleep seconds, waking as soon as cancel is set; whether it is set.