Worker¶
worker
¶
Long-polling worker that runs workflow and activity tasks.
:class:Worker registers itself with the server for a given task queue, then
spawns poll loops for both workflow tasks and activity tasks. Each received
task is dispatched to the registered workflow class or activity function,
results are serialized, and success/failure commands are sent back to the
server. Workers drain in-flight tasks on shutdown up to a configurable
shutdown_timeout.
Most applications create one :class:Worker per task queue and pass it the
same :class:~durable_workflow.Client used for control-plane calls, plus
lists of workflow classes and activity callables registered via
:func:durable_workflow.workflow.defn and :func:durable_workflow.activity.defn.
Worker
¶
Worker(client, *, task_queue, workflows=(), activities=(), worker_id=None, poll_timeout=35.0, max_concurrent_workflow_tasks=10, max_concurrent_activity_tasks=10, shutdown_timeout=30.0, metrics=None)
Polls workflow and activity tasks and dispatches them to Python callables.
run_until
async
¶
Run this worker until a workflow reaches a terminal state.
This is intended for examples, smoke tests, and single-workflow scripts.
Long-running workers should call :meth:run and coordinate shutdown from
their process supervisor.