Hi! I've got a few scheduled jobs (mostly hourly) ...
# ask-community
a
Hi! I've got a few scheduled jobs (mostly hourly) that I need to avoid running during a weekly maintenance window. Are there any recommended best practices for doing this? Options I've thought of: 1. modify the schedule to not trigger for those times 2. add a step in every run to check if it should continue or not 3. allow the jobs to schedule, but do not allow them out of the queue during that time (so, modify the queued run controller). This has the appeal of better handling hourly partitioned jobs, as we don't need to handle rescheduling the missed partition. Perhaps I'm missing something obvious? Curious to hear how others have tackled something like this.
j
Hi @Adam Bloom options 1 and 2 sound reasonable to me. option 3 sounds possible but could be complicated, so if 1 or 2 meets your needs, that would be the path of least resistance
a
Thanks for the sanity check! Looks like all scheduling is cron based though? So I don't see how that'd work without something more complex than cron. Is there another method of evaluating schedules to determine if they should emit runs?
j
In addition to returning RunRequests, a schedule can also return SkipReasons. my thinking is that you would do this: if you run a schedule hourly but dont want it to run between 3 and 5 pm you would 1. write an hourly schedule 2. in the function body of the schedule check if the time is between 3 and 5 pm 3. if you are not between 3 and 5 pm, return a RunRequest 4. if you are between 3 and 5pm, return a SkipReason Here's some docs on skip reasons (taken from the sensors page, but the same concept applies for schedules). This use case seems pretty helpful for other users. I'll look into adding some better documentation on using skip reasons in schedules
j
yes, i would definitely recommend using the
@schedule
decorator in this case when you have custom logic
a
great, thanks @jamie! I'll give this a try.