prefect.task_runs
Classes
TaskRunWaiter
A service used for waiting for a task run to finish.
This service listens for task run events and provides a way to wait for a specific
task run to finish. This is useful for waiting for a task run to finish before
continuing execution.
The service is a singleton and must be started before use. The service will
automatically start when the first instance is created. A single websocket
connection is used to listen for task run events.
The service can be used to wait for a task run to finish by calling
TaskRunWaiter.wait_for_task_run
with the task run ID to wait for. The method
will return when the task run has finished or the timeout has elapsed.
The service will automatically stop when the Python process exits or when the
global loop thread is stopped.
Example:
add_done_callback
task_run_id
: The ID of the task run to wait for.callback
: The callback to call when the task run finishes.
instance
start
stop
wait_for_task_run
task_run_id
: The ID of the task run to wait for.timeout
: The maximum time to wait for the task run to finish. Defaults to None.
- The final state of the task run if available, None otherwise.