Skip to content

Commit 2336cf0

Browse files
Catch error in sdk when workflow instance not found
Signed-off-by: Elena Kolevska <[email protected]>
1 parent 7d05d6f commit 2336cf0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

examples/workflow/monitor.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ def send_alert(ctx, message: str):
6363

6464
wf_client = wf.DaprWorkflowClient()
6565
job_id = 'job1'
66-
status = None
67-
try:
68-
status = wf_client.get_workflow_state(job_id)
69-
except Exception:
70-
pass
66+
status = wf_client.get_workflow_state(job_id)
7167
if not status or status.runtime_status.name != 'RUNNING':
7268
# TODO update to use reuse_id_policy
7369
instance_id = wf_client.schedule_new_workflow(

ext/dapr-ext-workflow/dapr/ext/workflow/dapr_workflow_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,12 @@ def get_workflow_state(
130130
exist.
131131
132132
"""
133-
state = self.__obj.get_orchestration_state(instance_id, fetch_payloads=fetch_payloads)
134-
return WorkflowState(state) if state else None
133+
try:
134+
state = self.__obj.get_orchestration_state(instance_id, fetch_payloads=fetch_payloads)
135+
return WorkflowState(state) if state else None
136+
except Exception as error:
137+
self._logger.error(f'Error fetching workflow state: {error}')
138+
return None
135139

136140
def wait_for_workflow_start(
137141
self, instance_id: str, *, fetch_payloads: bool = False, timeout_in_seconds: int = 60

0 commit comments

Comments
 (0)