Skip to content

Conversation

@VegetarianOrc
Copy link
Contributor

What was changed

  • Update to latest Nexus API
  • Implement task cancellation for nexus tasks (not to be confused with operation cancellation)

Why?

Nexus operation handlers should be able to handle the case where a call start_operation or call to cancel_operation is interrupted. The most common occurrence of this is a timeout where the call fails to return in time. The new cancellation objects attached to the Nexus operation context allows both sync and async functions to exit early when appropriate.

These changes rely on nexus-rpc/sdk-python#31 and is the Temporal specific implementation of nexus-rpc/sdk-python#26.

Checklist

  1. How was this tested:
  • Existing Nexus tests were updated to support the new Nexus API.
  • Tests in test/nexus/test_workflow_caller_errors.py were updated to cover:
    • StartOperation cancel (sync & async flavors)
    • CancelOperation cancel
  1. Any docs updates needed?

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking

@VegetarianOrc VegetarianOrc marked this pull request as ready for review November 17, 2025 20:20
@VegetarianOrc VegetarianOrc requested a review from a team as a code owner November 17, 2025 20:20
@abstractmethod
async def start_operation(
self,
operation: Callable[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure about this.

At the workflow level, we should be seeing the ServiceDefinition (i.e. not the implementation), which should not expose the notion of factory-style operation handlers (that's an implementation detail, not part of the public contract of a service).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. Removing this and updating the test to define the service and use that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, let's move on with this. We'll review pertinence of all overloads in another issue.

@VegetarianOrc VegetarianOrc merged commit 5d1630d into main Nov 17, 2025
26 of 27 checks passed
@VegetarianOrc VegetarianOrc deleted the nexus-task-cancellation branch November 17, 2025 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants