2121 sync_operation ,
2222)
2323
24- from temporalio import workflow
24+ from temporalio import nexus , workflow
2525from temporalio .client import (
2626 Client ,
2727 WorkflowFailureError ,
@@ -47,6 +47,13 @@ class ErrorTestInput:
4747 id : str
4848
4949
50+ @workflow .defn
51+ class NonTerminatingWorkflow :
52+ @workflow .run
53+ async def run (self ) -> None :
54+ await asyncio .Event ().wait ()
55+
56+
5057@nexusrpc .handler .service_handler
5158class ErrorTestService :
5259 @nexusrpc .handler .sync_operation
@@ -87,6 +94,18 @@ def retried_due_to_internal_handler_error(
8794 type = nexusrpc .HandlerErrorType .INTERNAL ,
8895 )
8996
97+ @nexusrpc .handler .sync_operation
98+ async def fails_due_to_workflow_already_started (
99+ self , ctx : nexusrpc .handler .StartOperationContext , input : ErrorTestInput
100+ ) -> None :
101+ operation_invocation_counts [input .id ] += 1
102+ for _ in range (2 ):
103+ await nexus .client ().start_workflow (
104+ NonTerminatingWorkflow .run ,
105+ id = "second-start-request-will-fail" ,
106+ task_queue = nexus .info ().task_queue ,
107+ )
108+
90109
91110@workflow .defn (sandboxed = False )
92111class CallerWorkflow :
@@ -156,6 +175,11 @@ async def times_called() -> int:
156175 nexusrpc .HandlerErrorType .NOT_FOUND ,
157176 "No handler for service" ,
158177 ),
178+ (
179+ "fails_due_to_workflow_already_started" ,
180+ nexusrpc .HandlerErrorType .INTERNAL ,
181+ "already started" ,
182+ ),
159183 ],
160184)
161185async def test_nexus_operation_fails_without_retry_as_handler_error (
0 commit comments