justabill
05/04/2023, 8:12 PMon_crashed
hook for flows, allowing you to add client-side hooks that will be called when your flow crashes. This is useful for cases where you want to execute code without involving the Prefect API, and for custom handling on CRASHED
terminal states. This callable hook will receive three arguments: flow
, flow_run
, and state
.
from prefect import flow
def crash_hook(flow, flow_run, state):
print("Don't Panic! But the flow has crashed...")
@flow(on_crashed=[crash_hook])
def my_flow():
# call `crash_hook` if this flow enters a `CRASHED` state
pass
Check out the release notes for more information.