Ravish Mallya
09/24/2025, 4:02 PMMarvin
09/24/2025, 4:02 PMMarvin
09/24/2025, 4:04 PMwait_for_flow_run
will keep waiting across retries. If the child flow run fails and enters `AwaitingRetry`/`Retrying`, the call will continue to block until the run reaches a terminal state (Completed, Failed, Cancelled, or Crashed) or until the timeout elapses.
- Default timeout is 3 hours; you can raise it to cover your full retry/backoff window.
- If the timeout is hit first, it raises FlowRunWaitTimeout
.
- On success or failure, it returns the FlowRun
model containing the final state; you can inspect flow_run.state.type
.
Example:
from prefect.deployments import run_deployment
from prefect.flow_runs import wait_for_flow_run
# Kick off a deployment
fr = run_deployment("my-project/my-deployment")
# Wait across any retries until terminal state
final = wait_for_flow_run(fr.id, timeout=6 * 3600, log_states=True)
print(final.state.type) # e.g., "COMPLETED", "FAILED", "CANCELLED", "CRASHED"
Links:
- Source for `wait_for_flow_run`: prefect/flow_runs.py
- State types in Prefect: States (Prefect 3.x)