Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion temporalio/nexus/_operation_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ class Info:

def in_operation() -> bool:
"""Whether the current code is inside a Nexus operation."""
return _try_temporal_context() is not None
start_ctx = _temporal_start_operation_context.get(None)
cancel_ctx = _temporal_cancel_operation_context.get(None)
if start_ctx and cancel_ctx:
raise RuntimeError("Cannot be in both start and cancel operation contexts.")
return (start_ctx or cancel_ctx) is not None


def info() -> Info:
Expand Down