https://prefect.io logo
Title
a

Amit Singh

07/09/2020, 2:26 PM
<!here> Is there a way to remove/stop a schedule attached to a flow at runtime. I want to ensure the flow stops only before the next scheduled iteration. Just killing the script might stop the current execution abruptly.
with Flow('Dummy Cron Flow', schedule=CronSchedule("*/1 * * * *")) as cron_flow:
👀 1
d

Dylan

07/09/2020, 2:31 PM
Hey @Amit Singh, If you’re using a Prefect orchestration layer (Prefect Cloud or Prefect Server), then you can turn off the schedule and manually schedule a Flow Run for the time you’d like. For a Prefect Core only implementation, the Flow’s schedule is tied to the running process as far as I know.
You’ll have to stop the process in order to change the schedule
Also, please try to reserve
@here
for emergencies that might affect others in the community (Cloud is down, for example) We do our best to be responsive here during business hours and we promise we’ll get to your question as soon as we can
a

Amit Singh

07/09/2020, 2:33 PM
Got it. Thanks a lot
d

Dylan

07/09/2020, 2:34 PM
Of course!
To clarify the above, with an orchestration layer, turning off a flow’s schedule does not interrupt any flow runs in a
Running
state
👍 1
a

Amit Singh

07/09/2020, 2:59 PM
@Dylan Does it also create a new instance of flow for each scheduled iteration. I mean - lets say it is scheduled every 5 mins, and the first execution has not completed before the next one kicks in
d

Dylan

07/09/2020, 3:04 PM
Hey @Amit Singh, that depends on how your agent and execution resources are structured. But yes, if resources are available that is the expected behavior
However, if you want to avoid this, your flow can query the GraphQL API to see if there are any Running flow runs and if so put itself in a
Cancelled
state
I have a flow that’s triggered by a DB pressure alert (via a google cloud function) that kills all flow runs with a certain label to make sure we don’t take down our database in times of high traffic/stress
We’re also looking at
flow_run_concurrency
as a feature (coming soon) where you’d be able to limit flows with a certain label to a certain number of runs
Keep an eye out for that!
a

Amit Singh

07/09/2020, 3:16 PM
That helps. thanks
d

Dylan

07/09/2020, 3:17 PM
Anytime!