News for hackers. Stuff that matters.
Re:Show HN: Rocketry – Statement-based scheduling framework ... by laserlight on Thursday September 22, 2022 @05:51AM (#32936733)
Hmm, this definition reads a bit wrong:

  @app.task((weekly.on("Mon") | weekly.on("Sat")) & time_of_day.after("10:00"))
  def do_twice_a_week_after_ten():
Expression reads Monday or Saturday, yet its meaning is Monday and Sunday according to function name.
Re:Show HN: Rocketry – Statement-based scheduling framework ... by andijcr on Thursday September 22, 2022 @05:58AM (#32936787)
if you take it as a boolean test it makes sense. it will be true for any timepoint that is after ten and is either on monday or saturday
Re:Show HN: Rocketry – Statement-based scheduling framework ... by Miksus on Thursday September 22, 2022 @06:09AM (#32936864)
Yep, exactly. Rocketry works on conditions which are either true or false thus you need to give it a time range.

Points in time do not actually make much sense in terms of scheduling as nothing can be run exactly at specified point. There should always be some buffer of tolerance. I think Cron has a tolerance of a minute or so and in Rocketry the tolerance is made obvious and completely customized.

For those interested more about those two types of time conditions. "time_of_..." are conditions that check whether the current time is in the specified range. The "secondly", "minutely", "hourly", "daily" etc. also check that current time is as specified but also that the task did not yet run on the interval. By combining the two you can create quite complex scheduling strategies easily.

Re:Show HN: Rocketry – Statement-based scheduling framework ... by BeefWellington on Thursday September 22, 2022 @08:13AM (#32937774)
It would simplify things a little if the weekly.on accepted multiple days, so you could reduce it to one call:

    weekly.on("Mon", "Sat")
Re:Show HN: Rocketry – Statement-based scheduling framework ... by Miksus on Thursday September 22, 2022 @08:25AM (#32937898)
That's a great idea actually. Thanks, I think that should be pretty easy to do!
Re:Show HN: Rocketry – Statement-based scheduling framework ... by drothlis on Thursday September 22, 2022 @06:40AM (#32937076)
`|` is a bitwise-or in Python, not a boolean-or.
Re:Show HN: Rocketry – Statement-based scheduling framework ... by laserlight on Thursday September 22, 2022 @09:02AM (#32938238)
That's right, but it doesn't change how the expression is read.