forked from temporalio/samples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow.py
More file actions
25 lines (21 loc) · 761 Bytes
/
workflow.py
File metadata and controls
25 lines (21 loc) · 761 Bytes
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
import asyncio
from datetime import timedelta
from temporalio import workflow
with workflow.unsafe.imports_passed_through():
from custom_metric.activity import print_and_sleep
@workflow.defn
class StartTwoActivitiesWorkflow:
@workflow.run
async def run(self):
# Request two concurrent activities with only one task slot so
# we can see nontrivial schedule to start times.
activity1 = workflow.execute_activity(
print_and_sleep,
start_to_close_timeout=timedelta(seconds=5),
)
activity2 = workflow.execute_activity(
print_and_sleep,
start_to_close_timeout=timedelta(seconds=5),
)
await asyncio.gather(activity1, activity2)
return None