nexusrpc.handler.OperationTaskCancellation

Indicates whether a a Nexus task has been cancelled during a sync operation or before an async operation has returned a token.

Nexus worker implementations are expected to provide an implementation that enables cooperative cancellation for both sync and async operation handlers.

Operation Handler implementations are expected to periodically check is_cancelled or use wait_until_cancelled / wait_until_cancelled_sync to cancel in flight work when appropriate.

Method cancellation_reason Provide additional context for the cancellation, if available.
Method is_cancelled Return True if the associated task has been cancelled.
Async Method wait_until_cancelled Await cancellation using async primitives. Nexus worker implementations may return True for is_cancelled before this method returns and therefore may cause a race condition if both are used in tandem.
Method wait_until_cancelled_sync Block until cancellation occurs or the optional timeout elapses. Nexus worker implementations may return True for is_cancelled before this method returns and therefore may cause a race condition if both are used in tandem.

Provide additional context for the cancellation, if available.

Return True if the associated task has been cancelled.

Await cancellation using async primitives. Nexus worker implementations may return True for is_cancelled before this method returns and therefore may cause a race condition if both are used in tandem.

Block until cancellation occurs or the optional timeout elapses. Nexus worker implementations may return True for is_cancelled before this method returns and therefore may cause a race condition if both are used in tandem.