<@ULVA73B9P> when adding retries to a task, will t...
# ask-marvin
f
@Marvin when adding retries to a task, will the on_failure hooks run after each try, or after retries has been exhausted?
m
thought for 128.9 seconds
Short answer: after retries are exhausted. In Prefect 3.x,
on_failure
hooks run when the task ultimately enters a Failed state. During retries, failed attempts transition the task into `AwaitingRetry`/`Retrying` (both are running-type states), so
on_failure
does not fire on each attempt. If you want something to run on every attempt, use
on_running
hooks—they fire on each run and retry. References: - Task engine hook handling in source: task_engine.py (hooks are called based on the final state entered) If you’re on Prefect 2.x, let me know—behavior and APIs differ there.