-
Notifications
You must be signed in to change notification settings - Fork 57
/
workflow.py
34 lines (28 loc) · 1.01 KB
/
workflow.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
from datetime import timedelta
from temporalio import workflow
with workflow.unsafe.imports_passed_through():
from gevent_async.activity import (
ComposeGreetingInput,
compose_greeting_async,
compose_greeting_sync,
)
@workflow.defn
class GreetingWorkflow:
@workflow.run
async def run(self, name: str) -> str:
workflow.logger.info("Running workflow with parameter %s" % name)
# Run an async and a sync activity
async_res = await workflow.execute_activity(
compose_greeting_async,
ComposeGreetingInput("Hello", name),
start_to_close_timeout=timedelta(seconds=10),
)
sync_res = await workflow.execute_activity(
compose_greeting_sync,
ComposeGreetingInput("Hello", name),
start_to_close_timeout=timedelta(seconds=10),
)
# Confirm the same, return one
if async_res != sync_res:
raise ValueError("Results are not the same")
return sync_res