prefect.task_worker
Functions
should_try_to_read_parameters
create_status_server
serve
.submit
the same task object that you pass to serve
.
Args:
- tasks
: A list of tasks to serve. When a scheduled task run is found for a given task, the task run will be submitted to the engine for execution.- limit
: The maximum number of tasks that can be run concurrently. Defaults to 10. PassNone
to remove the limit.- status_server_port
: An optional port on which to start an HTTP server exposing status information about the task worker. If not provided, no status server will run.- timeout
: If provided, the task worker will exit after the given number of seconds. Defaults to None, meaning the task worker will run indefinitely.
store_parameters
result_store
: The result store to store the parameters in.identifier
: The identifier of the task run.parameters
: The parameters to store.
read_parameters
result_store
: The result store to read the parameters from.identifier
: The identifier of the task run.
- The parameters for the task run.
Classes
StopTaskWorker
Raised when the task worker is stopped.
TaskWorker
This class is responsible for serving tasks that may be executed in the background
by a task runner via the traditional engine machinery.
When start()
is called, the task worker will open a websocket connection to a
server-side queue of scheduled task runs. When a scheduled task run is found, the
scheduled task run is submitted to the engine for execution with a minimal EngineContext
so that the task run can be governed by orchestration rules.
Args:
- tasks
: A list of tasks to serve. These tasks will be submitted to the engine when a scheduled task run is found.- limit
: The maximum number of tasks that can be run concurrently. Defaults to 10. PassNone
to remove the limit.
available_tasks
client_id
current_tasks
execute_task_run
handle_sigterm
limit
start
timeout
: If provided, the task worker will exit after the given number of seconds. Defaults to None, meaning the task worker will run indefinitely.