forked from temporalio/samples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.py
More file actions
34 lines (25 loc) · 890 Bytes
/
Copy pathworker.py
File metadata and controls
34 lines (25 loc) · 890 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
import asyncio
import logging
from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from temporalio.worker import Worker
from resource_pool.pool_client.resource_pool_workflow import ResourcePoolWorkflow
from resource_pool.resource_user_workflow import ResourceUserWorkflow, use_resource
async def main() -> None:
logging.basicConfig(level=logging.INFO)
# Start client
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)
# Run a worker for the workflow
worker = Worker(
client,
task_queue="resource_pool-task-queue",
workflows=[ResourcePoolWorkflow, ResourceUserWorkflow],
activities=[
use_resource,
],
)
await worker.run()
if __name__ == "__main__":
asyncio.run(main())