Prefect states contain information about the status of a flow or task run.
Scheduled
to run for the third time in an hourLate
because the associated worker process is not respondingScheduled
to run, but later Cancelled
via button in the UICached
from a previous run instead of Running
againCompleted
after Running
among its fellow task runsFailed
because Claude left pydantic 1.x syntax in your codeCrashed
because you Ctrl-C’d the processRUNNING
. However, if the task retries,
that same task run will have the name Retrying and the type RUNNING
.
State types drive orchestration logic, whereas state names provide visual bookkeeping.
The full list of states and state types includes:
Name | Type | Terminal? | Description |
---|---|---|---|
Scheduled | SCHEDULED | No | The run will begin at a particular time in the future. |
Late | SCHEDULED | No | The run’s scheduled start time has passed, but it has not transitioned to PENDING (15 seconds by default). |
AwaitingRetry | SCHEDULED | No | The run did not complete successfully because of a code issue and had remaining retry attempts. |
Pending | PENDING | No | The run has been submitted to execute, but is waiting on necessary preconditions to be satisfied. |
Running | RUNNING | No | The run code is currently executing. |
Retrying | RUNNING | No | The run code is currently executing after previously not completing successfully. |
Paused | PAUSED | No | The run code has stopped executing until it receives manual approval to proceed. |
Cancelling | CANCELLING | No | The infrastructure on which the code was running is being cleaned up. |
Cancelled | CANCELLED | Yes | The run did not complete because a user determined that it should not. |
Completed | COMPLETED | Yes | The run completed successfully. |
Cached | COMPLETED | Yes | The run result was loaded from a previously cached value. |
RolledBack | COMPLETED | Yes | The run completed successfully but the transaction rolled back and executed rollback hooks. |
Failed | FAILED | Yes | The run did not complete because of a code issue and had no remaining retry attempts. |
Crashed | CRASHED | Yes | The run did not complete because of an infrastructure issue. |
From | To | Triggered By | Explanation | |
---|---|---|---|---|
✅ | None | Scheduled | Manual run, automation, or schedule | A flow run has been created and scheduled for future execution. |
✅ | Scheduled | Pending | Worker | A worker is attempting to start the infrastructure for your flow run. |
⛔ | Scheduled | Late | Cloud or self-hosted server | Typically means that a worker did not pick up the run because 1) no workers are healthy, 2) workers are not polling the right work pool or work queue, or 3) workers are concurrency limited. |
✅ | Pending | Running | Worker | The infrastructure was provisioned and the flow is running |
⛔ | Pending | Crashed | Worker or runner | Something went wrong. Some possibilities are 1) the worker could have failed to create the infrastructure, 2) the code is not present in storage or the worker failed to authenticate, or 3) the code has missing or broken imports, or syntax errors. |
✅ | Running | Completed | Flow run | The flow completed successfully. |
⛔ | Running | Failed | Flow run | This usually means that your code raised an exception, check the flow run logs. |
⛔ | Running | Crashed | Worker or flow run | Probably not a raised exception in your code, but could be an infrastructure issue such as 1) an out of memory error, 2) an evicted pod, or 3) a timeout. |
COMPLETED
: a run in any COMPLETED
state did not encounter any errors or exceptions and returned successfullyFAILED
: a run in any FAILED
state encountered an error during execution, such as a raised exceptionCRASHED
: a run in any CRASHED
state was interrupted by an OS signal such as a KeyboardInterrupt
or SIGTERM
Completed
state if it returns any Python object, with one exception:
if a task explicitly returns a Prefect Failed
state, the task will be marked Failed
.
return_state
flag:
State
via return_state=True
is useful when you want to conditionally respond to the terminal states of a task or flow. For example, if state.is_failed(): ...
.FAILED
.FAILED
state will cause the run to be marked as FAILED
.COMPLETED
.
state
were returned from the flow function, the run would be marked as FAILED
.