forked from temporalio/samples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_worker.py
35 lines (26 loc) · 973 Bytes
/
run_worker.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
import asyncio
import concurrent.futures
import logging
from temporalio.client import Client
from temporalio.worker import Worker
from workflows import EntityBedrockWorkflow
from bedrock.shared.activities import BedrockActivities
async def main():
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
activities = BedrockActivities()
# Run the worker
with concurrent.futures.ThreadPoolExecutor(max_workers=100) as activity_executor:
worker = Worker(
client,
task_queue="bedrock-task-queue",
workflows=[EntityBedrockWorkflow],
activities=[activities.prompt_bedrock],
activity_executor=activity_executor,
)
await worker.run()
if __name__ == "__main__":
print("Starting worker")
print("Then run 'python send_message.py \"<prompt>\"'")
logging.basicConfig(level=logging.INFO)
asyncio.run(main())