forked from temporalio/samples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_worker.py
38 lines (31 loc) · 1.06 KB
/
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
36
37
38
import asyncio
from concurrent.futures import ThreadPoolExecutor
from temporalio.client import Client
from temporalio.worker import Worker
from temporalio.worker.workflow_sandbox import (
SandboxedWorkflowRunner,
SandboxRestrictions,
)
from cloud_export_to_parquet.data_trans_activities import (
data_trans_and_land,
get_object_keys,
)
from cloud_export_to_parquet.workflows import ProtoToParquet
async def main() -> None:
"""Main worker function."""
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
# Run the worker
worker: Worker = Worker(
client,
task_queue="DATA_TRANSFORMATION_TASK_QUEUE",
workflows=[ProtoToParquet],
activities=[get_object_keys, data_trans_and_land],
workflow_runner=SandboxedWorkflowRunner(
restrictions=SandboxRestrictions.default.with_passthrough_modules("boto3")
),
activity_executor=ThreadPoolExecutor(100),
)
await worker.run()
if __name__ == "__main__":
asyncio.run(main())