forked from temporalio/samples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwake_up_time_updater.py
More file actions
31 lines (22 loc) · 893 Bytes
/
wake_up_time_updater.py
File metadata and controls
31 lines (22 loc) · 893 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
26
27
28
29
30
31
import asyncio
import logging
from datetime import datetime, timedelta
from typing import Optional
from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from updatable_timer.workflow import Workflow
async def main(client: Optional[Client] = None):
logging.basicConfig(level=logging.INFO)
if not client:
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)
handle = client.get_workflow_handle(workflow_id="updatable-timer-workflow")
# signal workflow about the wake up time change
await handle.signal(
Workflow.update_wake_up_time,
(datetime.now() + timedelta(seconds=10)).timestamp(),
)
logging.info("Updated wake up time to 10 seconds from now")
if __name__ == "__main__":
asyncio.run(main())