Python SDK Reference
task_engine
prefect.task_engine
Functions
run_task_sync
↗
run_generator_task_sync
↗
run_task
↗
Runs the provided task.
Args:
task
: The task to runtask_run_id
: The ID of the task run; if not provided, a new task run will be createdtask_run
: The task run object; if not provided, a new task run will be createdparameters
: The parameters to pass to the taskwait_for
: A list of futures to wait for before running the taskreturn_type
: The return type to return; either “state” or “result”dependencies
: A dictionary of task run inputs to use for dependency trackingcontext
: A dictionary containing the context to use for the task run; only required if the task is running on in a remote environment
Returns:
- The result of the task run
Classes
TaskRunTimeoutError
↗
Raised when a task run exceeds its timeout.
BaseTaskRunEngine
↗
Methods:
state
↗
is_cancelled
↗
compute_transaction_key
↗
record_terminal_state_timing
↗
is_running
↗
Whether or not the engine is currently running a task.
log_finished_message
↗
handle_rollback
↗
SyncTaskRunEngine
↗
Methods:
client
↗
can_retry
↗
call_hooks
↗
begin_run
↗
set_state
↗
result
↗
handle_success
↗
handle_retry
↗
Handle any task run retries.
- If the task has retries left, and the retry condition is met, set the task to retrying and return True.
- If the task has a retry delay, place in AwaitingRetry state with a delayed scheduled time.
- If the task has no retries left, or the retry condition is not met, return False.
handle_exception
↗
handle_timeout
↗
handle_crash
↗
setup_run_context
↗
asset_context
↗
initialize_run
↗
Enters a client context and creates a task run if needed.
start
↗
transaction_context
↗
run_context
↗
call_task_fn
↗
Convenience method to call the task function. Returns a coroutine if the task is async.
AsyncTaskRunEngine
↗
Methods: