Hi all! I have a question about the Schedulers… If...
# ask-community
j
Hi all! I have a question about the Schedulers… If I use two clocks, and both of them trigger at the same time, is my flow executed just once? Thank you!
a
if you attach two clocks with the same time to your flow schedule, this will result in 2 separate flow runs of your flow. Are you using this to run the same flow twice, each with different parameters?
k
I think it will be just once if you are only using Prefect Core without Cloud. If you use a backend (Cloud or Server), it should work
j
Yes @Anna Geller ,my exact use case is the following: I have a flow that send emails every day. But I want to delay the emails sent on weekends to the next Monday. The way I’m trying to do this is by using the adjustments argument in Schedule, and if dt is on weekend add 1 or 2 days. To test if this works I am trying a PoC locally using Prefect Core. I checked that at “monday” the three clocks should trigger 3 flows, but only 1 is executed. As @Kevin Kho said it might be because I am using Prefect Core and not Prefect Cloud or Prefect Server. I will try with Prefect Server (in production I will use Prefect Cloud). Thank you very much!
k
You may as well just use Cloud is you can because there are 20k task runs for free every month and it’s a lot easier to start with
j
Yes you’re right, and I test the real environment. Thank you!
👍 1
Oh..I just discovered that this approach does not fit for me, because I need to know the original schedule time to send the email correctly configured, and the adjustemnt modifies the schedule time, and context variables refers to the execution time, so I cannot know which flow run must be related to saturday, to sunday or to monday
k
There was someone who had this exact issue. Let me see what they did if it’s still around
j
@Kevin Kho, I think it was me hahaha
k
Are you the one who said you didn’t want notifications over the weekend?
That thread is gone btw
j
Yeah that is! 😄
k
Ah ok. This is pretty tricky. Let me think for a bit
j
With my knowledge, the only thing that comes to my mind is to use 3 clocks. One for weekdays, other just for mondays and a
parameter_defaults
that subtract 1 day, and other just for mondays that subtract 2 days again using the
parameter_defaults
. (that was the solution we thought that it was better!) I don’t know if you have faced this feature before (delay of a flow run for X days, but need to be executed as if it were the original date), and if the previously described solution is the best approach nowadays. Again thank you very much!
k
I have a few ideas but they don’t feel good. 1. Split out the notification to it’s own subflow. Even if the flow runs over the weekend, the notification can be delayed by passing
scheduled_start_time
, and you can also pass
parameters
to identify the date that ran. This allows you to separate notification versus execution. 2. Have a main flow that kicks off subflows for the weekend run. You can provide a
new_flow_context
to
StartFlowRun
. So maybe you can edit the context even with a different
scheduled_start_time
. I think one might be the best bet
j
Yes, I like approach 1 very much, I didn’t thought about it. Thank you very much!