OperationCancelled

OperationCancelled#

exception rapidtools.core.OperationCancelled[source]#

Bases: RuntimeError

Raised by a component when its cancel_event has been set.

The exception derives from RuntimeError so that callers who do not care about cancellation specifically can still catch it with a generic handler, while callers that do can distinguish a user-requested stop from a genuine failure.

Example

>>> import threading
>>> from rapidtools.core import OperationCancelled, raise_if_cancelled
>>>
>>> stop = threading.Event()
>>> stop.set()
>>> try:
...     raise_if_cancelled(stop, context='tiling')
... except OperationCancelled as exc:
...     print(exc)
Operation cancelled during tiling.