-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathrun_worker.py
More file actions
37 lines (29 loc) · 940 Bytes
/
Copy pathrun_worker.py
File metadata and controls
37 lines (29 loc) · 940 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
32
33
34
35
36
37
"""Worker for the activity interrupt sample."""
# @@@SNIPSTART python-strands-activity-interrupt-worker
import asyncio
import os
from temporalio.client import Client
from temporalio.contrib.strands import StrandsPlugin
from temporalio.worker import Worker
from strands_plugin.activity_interrupt.workflow import (
ActivityInterruptWorkflow,
delete_thing,
)
async def main() -> None:
plugin = StrandsPlugin()
# The plugin MUST be on the client so its failure converter is installed.
client = await Client.connect(
os.environ.get("TEMPORAL_ADDRESS", "localhost:7233"),
plugins=[plugin],
)
worker = Worker(
client,
task_queue="strands-activity-interrupt",
workflows=[ActivityInterruptWorkflow],
activities=[delete_thing],
)
print("Worker started. Ctrl+C to exit.")
await worker.run()
if __name__ == "__main__":
asyncio.run(main())
# @@@SNIPEND