Hi ) How do I make sure a Prefect flow which is sc...
# ask-community
a
Hi ) How do I make sure a Prefect flow which is scheduled to run each 10 mins is NOT run if the previous run is still in progress?
k
Hey @Anatoly Alekseev, you need to use the state handler to query the graphQL API and check if there is a running flow. If there is, you can just
return Success
If you are on Cloud, you can do this with a combination of Flow Run concurrency limits on that flow so that the next one will just be queued, and Automations to cancel flow runs that have been queued for X minutes.
👍 1
a
Thank you so much Kevin for the prompt response. Since Prefect is positioned as an advanced scheduler, I was kinda expecting it to have basic functionality that, let's say, Windows task scheduler has: ie, what to do, if a particular task is scheduled, but one or more instances of it are already running. It feels so natural to specify this behavior at the flow config/creation step... Maybe Prefect team needs to put it on their TODO list.
k
Just chatted with the team and the linear schedulling like this is being worked on.
🙏 1
m
@Anatoly Alekseev I ran into the same thing with a couple of my flows. I have a task that runs at the beginning of the flow which queries the API to check for other flows still in progress. It's also configurable in the case where you want to let the flow continue running as long as it's executed with different parameters. you can check it out here: https://gist.github.com/mhmcdonald/0a848ecb44ecd6a77aeae9027fcb4fbb
upvote 1
k
@Marvin archive “Throttling Consecutive Flow Runs”