If I encounter a certain condition in a flow run, ...
# ask-community
m
If I encounter a certain condition in a flow run, I'd like to cancel the flow run (rather than fail it or mark it successful). It doesn't seem like there is a way to do this from prefect.engine.signals. Is there any way to do this (apart from the UI)? https://docs.prefect.io/core/concepts/execution.html#state-signals
k
Hey @Mark McDonald, I think if you don’t want to use FAIL or SKIP, then you would need to use a state handler to hit the GraphQL API to cancel the run. This is a best effort thing because it’s hard to stop processing that is happening on other compute (think of stuff sent to a Dask cluster). See this recent issue. You can also maybe use a terminal state handler at the end to check if the last task had a TRIGGERFAILED or SKIPPED, and then return a cancelled state from that
m
that makes sense - thanks