-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.py
More file actions
33 lines (25 loc) · 770 Bytes
/
worker.py
File metadata and controls
33 lines (25 loc) · 770 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
import asyncio
import logging
import os
from dotenv import load_dotenv
from registry import ACTIVITIES, WORKFLOWS
from tc_temporal_backend.client import TemporalClient
from temporalio.worker import Worker
async def main():
# Initialize environment
load_dotenv()
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=WORKFLOWS,
activities=ACTIVITIES,
)
logging.info("Starting worker...")
await worker.run()
if __name__ == "__main__":
asyncio.run(main())