-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtemporal_worker.py
More file actions
35 lines (26 loc) · 922 Bytes
/
temporal_worker.py
File metadata and controls
35 lines (26 loc) · 922 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
import asyncio
import logging
import os
from dotenv import load_dotenv
from tc_temporal_backend.client import TemporalClient
from temporal_tasks import HivemindWorkflow, hivemind_temporal_activity
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
async def main():
load_dotenv()
logging.basicConfig(level=logging.INFO)
task_queue = os.getenv("TEMPORAL_TASK_QUEUE")
if not task_queue:
raise ValueError("`TEMPORAL_TASK_QUEUE` is not properly set!")
logging.info(f"Using task queue: {task_queue}")
client = await TemporalClient().get_client()
worker = Worker(
client,
task_queue=task_queue,
workflows=[HivemindWorkflow],
activities=[hivemind_temporal_activity],
workflow_runner=UnsandboxedWorkflowRunner(),
)
logging.info("Starting worker...")
await worker.run()
if __name__ == "__main__":
asyncio.run(main())