-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathstarter.py
32 lines (25 loc) · 949 Bytes
/
starter.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
import asyncio
import logging
from datetime import datetime, timedelta
from typing import Optional
from temporalio import exceptions
from temporalio.client import Client
from updatable_timer import TASK_QUEUE
from updatable_timer.workflow import Workflow
async def main(client: Optional[Client] = None):
logging.basicConfig(level=logging.INFO)
client = client or await Client.connect("localhost:7233")
try:
handle = await client.start_workflow(
Workflow.run,
(datetime.now() + timedelta(days=1)).timestamp(),
id=f"updatable-timer-workflow",
task_queue=TASK_QUEUE,
)
logging.info(f"Workflow started: run_id={handle.result_run_id}")
except exceptions.WorkflowAlreadyStartedError as e:
logging.info(
f"Workflow already running: workflow_id={e.workflow_id}, run_id={e.run_id}"
)
if __name__ == "__main__":
asyncio.run(main())