Hello Prefect community, I am very new to Prefect....
# ask-community
o
Hello Prefect community, I am very new to Prefect. I was going through the documentation for suspend_flow_run for Prefect 3.0. I am having some difficulty because whenever I am using this method, it is telling me that RuntimeError: Cannot suspend task runs. I am basically trying to stop a flow from running after a specific condition is met. Can anyone share me how to suspend a flow? The docs do not have any example of suspending a flow. Thank you for your help in advance.
j
You mentioned it complained that it could not stop a task. Does your
@flow
have
@task
s? If so, you could turn those into `@flow`s and maybe your current attempt would work better?
a
Those functions are intended to run from within the body of a flow rather than a task. You could check the result of a task within the flow and have the flow decide to suspend based on the result. Also worth knowing is that with suspend, your flow is going to exit and then run again when it resumes. Putting as much as possible into cached task calls will help make the flow function reentrant. Anyway, if you’re still having trouble, share some code and we can check it out!