is_canceled#
- rapidtools.core.is_canceled(cancel_event: Event | None) bool[source]#
Return
Trueifcancel_eventexists and has been set.This is the non-raising counterpart of
raise_if_canceled(), 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_canceled >>> >>> stop = threading.Event() >>> is_canceled(None), is_canceled(stop) (False, False) >>> stop.set() >>> is_canceled(stop) True