-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstarter.py
More file actions
67 lines (55 loc) · 1.8 KB
/
starter.py
File metadata and controls
67 lines (55 loc) · 1.8 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import asyncio
import uuid
from temporalio.client import Client
from worker import (
HelloWorldWorkflow,
HelloWorldWorkflow2,
HelloWorldWorkflow3,
HelloWorldWorkflow4,
HelloWorldWorkflow5,
)
async def main():
client = await Client.connect("localhost:7233")
result1 = await client.execute_workflow(
HelloWorldWorkflow.run,
"World",
id=f"hello-world-{uuid.uuid4().hex[:8]}",
task_queue="hello-world-task-queue",
)
print(f"Workflow 1 result: {result1}")
result2 = await client.execute_workflow(
HelloWorldWorkflow2.run,
"World",
id=f"hello-world-2-{uuid.uuid4().hex[:8]}",
task_queue="hello-world-task-queue",
)
print(f"Workflow 2 result: {result2}")
result3 = await client.execute_workflow(
HelloWorldWorkflow3.run,
"World",
id=f"hello-world-3-{uuid.uuid4().hex[:8]}",
task_queue="hello-world-task-queue",
)
print(f"Workflow 3 result: {result3}")
# Start workflow 4 — it will run say_hello then pause waiting for a signal
wf4_id = f"hello-world-4-{uuid.uuid4().hex[:8]}"
wf4_handle = await client.start_workflow(
HelloWorldWorkflow4.run,
"World",
id=wf4_id,
task_queue="hello-world-task-queue",
)
print(f"Workflow 4 started (paused), id: {wf4_id}")
# Start workflow 5 — it signals workflow 4 to resume
result5 = await client.execute_workflow(
HelloWorldWorkflow5.run,
wf4_id,
id=f"hello-world-5-{uuid.uuid4().hex[:8]}",
task_queue="hello-world-task-queue",
)
print(f"Workflow 5 result: {result5}")
# Now wait for workflow 4 to complete
result4 = await wf4_handle.result()
print(f"Workflow 4 result: {result4}")
if __name__ == "__main__":
asyncio.run(main())