Hi <@ULVA73B9P>! On Prefect 3.0, what is the simpl...
# ask-marvin
m
Hi @Marvin! On Prefect 3.0, what is the simplest way to define a flow that will enter crashed state on purpose? This is to simulate crashed flows to test our response to them.
m
To simulate a crashed flow in Prefect 3.0, you can intentionally raise an exception within your flow. Here's a simple example that raises a
SystemExit
exception to cause the flow to crash:
Copy code
python
from prefect import flow

@flow
def boom_crash():
    raise SystemExit("Boom crash")

if __name__ == "__main__":
    boom_crash()
This flow,
boom_crash
, will enter a crashed state when run due to the
SystemExit
exception. You can use this to test your response to crashed flows. For more information, you can refer to the crashes.py example. If you need to handle exceptions to convert them to a 'Crashed' state, you might find the
exception_to_crashed_state
function in the Prefect codebase useful. Unfortunately, the exact usage isn't detailed in the documentation, but you can explore the source code for more insights.
🙌 1