Skip to content

Commit 95e36f2

Browse files
committed
HACK: restart workflow
1 parent adb563e commit 95e36f2

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

nexus_sync_operations/handler/service_handler.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from __future__ import annotations
88

99
import nexusrpc
10+
from temporalio import nexus
1011
from temporalio.client import Client, WorkflowHandle
1112
from temporalio.common import WorkflowIDConflictPolicy
1213

@@ -31,15 +32,20 @@ def __init__(
3132

3233
@classmethod
3334
async def create(cls, client: Client, task_queue: str) -> GreetingServiceHandler:
34-
# Obtain a workflow handle to the long-running workflow that baxks this service, starting
35+
# Obtain a workflow handle to the long-running workflow that backs this service, starting
3536
# the workflow if it is not already running.
36-
wf_handle = await client.start_workflow(
37+
return cls(await cls._get_workflow_handle(client, task_queue))
38+
39+
@staticmethod
40+
async def _get_workflow_handle(
41+
client: Client, task_queue: str
42+
) -> WorkflowHandle[GreetingWorkflow, str]:
43+
return await client.start_workflow(
3744
GreetingWorkflow.run,
3845
id="nexus-sync-operations-greeting-workflow",
3946
task_queue=task_queue,
4047
id_conflict_policy=WorkflowIDConflictPolicy.USE_EXISTING,
4148
)
42-
return cls(wf_handle)
4349

4450
@nexusrpc.handler.sync_operation
4551
async def get_languages(
@@ -77,6 +83,7 @@ async def set_language_using_activity(
7783
async def approve(
7884
self, ctx: nexusrpc.handler.StartOperationContext, input: ApproveInput
7985
) -> None:
80-
return await self.greeting_workflow_handle.signal(
81-
GreetingWorkflow.approve, input
86+
await self.greeting_workflow_handle.signal(GreetingWorkflow.approve, input)
87+
self.greeting_workflow_handle = await self._get_workflow_handle(
88+
nexus.client(), nexus.info().task_queue
8289
)

0 commit comments

Comments
 (0)