forked from temporalio/samples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflow_v2.py
36 lines (28 loc) · 1.01 KB
/
workflow_v2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import asyncio
from datetime import timedelta
from temporalio import workflow
with workflow.unsafe.imports_passed_through():
from worker_versioning.activities import greet
@workflow.defn
class MyWorkflow:
"""
The 2.0 version of the workflow, which is fully incompatible with the other workflows, since it
alters the sequence of commands without using `patched`.
"""
should_finish: bool = False
@workflow.run
async def run(self) -> str:
workflow.logger.info("Running workflow V2")
await workflow.wait_condition(lambda: self.should_finish)
return "Concluded workflow on V2"
@workflow.signal
async def proceeder(self, inp: str):
await asyncio.sleep(1)
await workflow.execute_activity(
greet, "V2", start_to_close_timeout=timedelta(seconds=5)
)
await workflow.execute_activity(
greet, "V2", start_to_close_timeout=timedelta(seconds=5)
)
if inp == "finish":
self.should_finish = True