Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Eileen-Yu committed Nov 26, 2024
1 parent 7d301e4 commit 0b8d9d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion workflows/python/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cd ..
name: Running this example
expected_stdout_lines:
- "There are now 90 cars left in stock"
- "Workflow completed! Result: Completed"
- "Workflow completed!"
output_match_mode: substring
background: true
timeout_seconds: 120
Expand Down
21 changes: 10 additions & 11 deletions workflows/python/sdk/order-processor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from dapr.clients import DaprClient
from dapr.conf import settings
from dapr.ext.workflow import DaprWorkflowClient
from dapr.ext.workflow import DaprWorkflowClient, WorkflowStatus

from workflow import wfr, order_processing_workflow
from model import InventoryItem, OrderPayload
Expand Down Expand Up @@ -80,23 +80,22 @@ def prompt_for_approval(wfClient: DaprWorkflowClient):

if not state:
print("Workflow not found!") # not expected
elif state.runtime_status in {"Completed", "Failed", "Terminated"}:
break

if state.runtime_status in {WorkflowStatus.COMPLETED, WorkflowStatus.FAILED, WorkflowStatus.TERMINATED}:
print(f'Workflow completed! Result: {state.runtime_status}', flush=True)
break


if time_delta.total_seconds() >= 10:
state = wfClient.get_workflow_state(instance_id=_id)
if state is None:
print("Workflow not found!") # not expected

else:
if total_cost > 50000 and (
state.runtime_status not in ["Completed", "Failed", "Terminated"]
) and not approval_seeked:
approval_seeked = True
threading.Thread(target=prompt_for_approval(wfClient), daemon=True).start()
if total_cost > 50000 and state not in {WorkflowStatus.COMPLETED, WorkflowStatus.FAILED, WorkflowStatus.TERMINATED} and not approval_seeked:
approval_seeked = True
threading.Thread(target=prompt_for_approval(wfClient), daemon=True).start()

wfr.shutdown()



def restock_inventory(self, daprClient: DaprClient, baseInventory):
for key, item in baseInventory.items():
Expand Down

0 comments on commit 0b8d9d0

Please sign in to comment.