Miksus / rocketry

Modern scheduling library for Python
https://rocketry.readthedocs.io
MIT License
3.28k stars 108 forks source link

ENH: Missfire/task missed condition #26

Open Miksus opened 2 years ago

Miksus commented 2 years ago

Is your feature request related to a problem? Please describe. If a task was missed (due to system failure, performance reasons or missing conditions), in some cases it is desired to run the missed task(s).

Describe the solution you'd like Run stacks or a condition that allows running tasks that were missed.

Maybe something like this:

@app.task("daily | missed")
def do_daily():
    ...

If this was missed (did not run yesterday), the missed should return True and the task should run again.

The solution needs to check the last time the task ran and compare whether that was inside the previous timespan of the condition.

Describe alternatives you've considered A metatask or a custom condition with a stack.

mutt0-ds commented 2 years ago

Hello, I would like to help with this task!

Miksus commented 2 years ago

Ye, help is very much needed! I'm thinking the condition mechanism might need some touches beforehand though. The conditions could have better parametrization. I'm not currently happy how the tasks are injected to the conditions and thinking if those should be changed to be less stateful: https://github.com/Miksus/red-engine/blob/master/redengine/core/task.py#L306

Maybe use a method like "check" with the task as a parameter when checking the condition instead of relying overriding __bool__.