is_cancelled#
- rapidtools.core.is_cancelled(cancel_event: Event | None) bool[source]#
Return
Trueifcancel_eventexists and has been set.This is the non-raising counterpart of
raise_if_cancelled(), useful in loops that want to exit gracefully and keep partial results.- Parameters:
cancel_event (Event | None) – The event to inspect.
Nonemeans cancellation is not enabled.- Returns:
bool –
Trueonly when an event was supplied and it is set.
Example
>>> import threading >>> from rapidtools.core import is_cancelled >>> >>> stop = threading.Event() >>> is_cancelled(None), is_cancelled(stop) (False, False) >>> stop.set() >>> is_cancelled(stop) True