4 ms·
I haven't looked too closely yet so please excuse me for asking this question but how dynamic can i make the timed events? I have two use-cases in mind: 1. I w
by lep 4y ago
I haven't looked too closely yet so please excuse me for asking this question but how dynamic can i make the timed events? I have two use-cases in mind:
1. I would like to run a task each day 30 minutes before dawn so i have to compute that time at some point.
2. I run a task normally every hour but if something happens i want to run it 20 minutes after that event.
- tonyhb 4y agoFor #2, you want an event driven scheduler that can coordinate between events. We've built this at https://www.inngest.com https://www.inngest.com. You can run functions based off of schedules or events, with things like "when this event happens, run 20 minutes after the event". Or, "run, wait for another thing to happen, then continue". Event driven schedulers do all the regular scheduling, but with a few benefits: - It's reactive - You can fan-out, so one event runs many functions - You can store all events for debugging, replay, local testing, typing, etc. We could plumb in an event source for #1 which indicates sunrise and sunset. Heh.
- xwowsersx 4y agoNice project and good looking page. Just fyi but the "s" in "background jobs" is a bit cut off for me (Chrome on Pixel 6 Pro) https://ibb.co/42j18fk https://ibb.co/42j18fk
- charlieyu1 4y agoIsn't it better to fetch dawn times everyday then set accordingly?
- jon-wood 4y agoGiven the "before dawn" constraint here I'm going to assume this is somehow related to home/building automation, in which case you should go look at Home Assistant, which has built in support for things like "do this every hour, or 20 minutes after device X was triggered" and indeed "do this 30 minutes before sunrise".
- lep 4y agoWell it's a mixed bag. The dusk/dawn stuff would just be like nice-to-have. I would like to be reminded 30m before dawn to for example walk the dog while the sun is _just_ still out. The other for example could be used for handling "social" events. Like some games only happen during evening hours where i check more often than in off-hours but if any game happens whenever i would like to handle it after the regular game time. Now, nothing of that would be too hard to implement myself but these task runners pop up every so often and i would like to leverage other peoples work. Home assistant just feels a bit big for this. Do note that i currently do neither of those but i always try to evaluate these use-cases for these task-runners.
- xani_ 4y agoWell, unless you like running in rain you'd have to feed it weather info too. On other side it would allow it to be fancy, like rescheduling it earlier if rain is close to the sunset
- powvans 4y agoCelery supports solar scheduling, though it's not obvious how you would do +/- some time from the solar event. You would probably need to extend their implementation, but I don't think that would be too hard. https://docs.celeryq.dev/en/stable/reference/celery.schedules.html#celery.schedules.solar https://docs.celeryq.dev/en/stable/reference/celery.schedule... EDIT: I think you just need to provide a nowfun that offsets datetime.now() by the desired timedelta.
- orwin 4y agohttps://sunrise-sunset.org/api https://sunrise-sunset.org/api I used this myself for my father's chicken coop, it's quite easy to use.
- lep 4y agoThanks but computing the time aint the hard part (modules are available for many languages). I'm more interested in how easy it is to fit this task into the scheduler.
- musingsole 4y agoYou can build arbitrary conditions (the example given is `file_exists`) that can run whatever code and only need to return True or False. If you can write the condition in English, it would seem to me you can build a custom Rocketry condition to suit it.
- xwowsersx 4y agoI'm not 100% sure, but take a look at the section on "Manipulating Other Tasks" https://rocketry.readthedocs.io/en/stable/cookbook/controlling_runtime.html#manipulating-other-tasks https://rocketry.readthedocs.io/en/stable/cookbook/controlli... It seems like what you could do is have a task that runs at some regular interval which would compute the 30 minutes before dawn each day and then add the task with the correct start time directly on the rocketry.args.Session: session.create_task(func=before_dawn_task, start_cond=some_condition)