Fredrik Hoem Grelland
11/24/2025, 10:07 AMMarvin
11/24/2025, 10:07 AMMarvin
11/24/2025, 10:09 AMon_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.