diff --git a/docs/develop/python/temporal-nexus.mdx b/docs/develop/python/temporal-nexus.mdx index 289c2b852f..efbab42016 100644 --- a/docs/develop/python/temporal-nexus.mdx +++ b/docs/develop/python/temporal-nexus.mdx @@ -324,16 +324,25 @@ In Python, there are three Nexus-specific exception classes: ## Canceling a Nexus Operation {#canceling-a-nexus-operation} - - To cancel a Nexus Operation from within a Workflow, call `handle.cancel()` on the operation handle. Only asynchronous operations can be canceled in Nexus, since cancellation is sent using an operation token. The Workflow or other resources backing the operation may choose to ignore the cancellation request. If ignored, the operation may enter a terminal state. +When a Nexus operation is started, the caller can specify different cancellation types that control how the caller reacts to cancellation: + +- `ABANDON` - Do not request cancellation of the operation. +- `TRY_CANCEL` - Initiate a cancellation request and immediately report cancellation to the caller. Note that this type doesn't guarantee that cancellation is delivered to the operation handler if the caller exits before the delivery is done. +- `WAIT_REQUESTED` Request cancellation of the operation and wait for confirmation that the request was received. Doesn't wait for actual cancellation. +- `WAIT_COMPLETED` - Wait for operation completion. Operation may or may not complete as cancelled. + +The default is `WAIT_COMPLETED`. Users can set a different option for `cancellation_type` when starting or executing an operation. + Once the caller Workflow completes, the caller's Nexus Machinery will not make any further attempts to cancel operations that are still running. It's okay to leave operations running in some use cases. To ensure cancellations are delivered, wait for all pending operations to finish before exiting the Workflow. +See the [Nexus cancellation sample](https://github.com/temporalio/samples-dotnet/tree/main/src/NexusCancellation) for reference. + ## Make Nexus calls across Namespaces in Temporal Cloud {#nexus-calls-across-namespaces-temporal-cloud} This section assumes you are already familiar with how to connect a Worker to Temporal Cloud.