-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathstarter.py
More file actions
43 lines (33 loc) · 1.09 KB
/
starter.py
File metadata and controls
43 lines (33 loc) · 1.09 KB
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
37
38
39
40
41
42
43
import asyncio
from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from prometheus.worker import GreetingWorkflow, init_runtime_with_prometheus
interrupt_event = asyncio.Event()
async def main():
runtime = init_runtime_with_prometheus(9001)
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
# Connect client
client = await Client.connect(
**config,
runtime=runtime,
)
# Run workflow
result = await client.execute_workflow(
GreetingWorkflow.run,
"Temporal",
id="prometheus-workflow-id",
task_queue="prometheus-task-queue",
)
print(f"Workflow result: {result}")
print(
"Prometheus client metrics available at http://127.0.0.1:9001/metrics, ctrl+c to exit"
)
await interrupt_event.wait()
if __name__ == "__main__":
loop = asyncio.new_event_loop()
try:
loop.run_until_complete(main())
except KeyboardInterrupt:
interrupt_event.set()
loop.run_until_complete(loop.shutdown_asyncgens())