Quick question about scheduling: is there a way to...
# prefect-community
Quick question about scheduling: is there a way to gracefully cancel a running (infinite) flow that uses a schedule? Also, I need to manage several of them in my application, so I plan to write some sort of management class for runs. Except, maybe something like this already exists, does anybody know?
Depending on your executor, this might be easier or harder to achieve. To cancel the running flow, simply kill the process — however, to do so gracefully, you’ll want to make sure the tasks are running in a different process. The DaskExecutor would work — in that case, the “controller” process would die, but the already-submitted tasks would continue running for at least one more pass through the flow.
An alternative would be to modify the
function to respect a global variable, perhaps something from a queue or elsewhere in your application. That way you could set a flag and exit the loop when required. (This is just off the top of my head, would require a little looking to confirm)
Thanks. I'll have a look at the run() function and see how that works. This sounds like the cleaner solution...