-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflows.py
36 lines (28 loc) · 1.06 KB
/
workflows.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 typing import List
from temporalio import workflow
# Import our activity, passing it through the sandbox
with workflow.unsafe.imports_passed_through():
from activities import greet
@workflow.defn
class VersioningExample:
def __init__(self) -> None:
self._pending_inputs: List[str] = []
@workflow.run
async def run(self) -> str:
workflow.logger.info("Workflow 2.1 started, waiting for signal.")
while True:
await workflow.wait_condition(lambda: self._pending_inputs)
input_value = self._pending_inputs.pop(0)
workflow.logger.info(f"Workflow V1 got signal: {input_value}")
await workflow.execute_activity(
f"from V2.2 workflow!",
greet,
start_to_close_timeout=timedelta(minutes=1),
)
if input_value == "finish":
return "Concluded workflow on 2.1"
@workflow.signal
def proceeder(self, input: str):
self._pending_inputs.append(input)