feat(server/cron): add allowExpiredTasks to execute overdue tasks#705
feat(server/cron): add allowExpiredTasks to execute overdue tasks#705st860923 wants to merge 1 commit intooverextended:masterfrom
Conversation
Introduces a new `allowExpiredTasks` option for cron jobs, allowing scheduled tasks to execute even if their scheduled time has already passed. Previously, tasks that were slightly overdue (due to server hitches or thread delays) were skipped, leading to inconsistencies in scheduling. With this change, if `allowExpiredTasks = true`, tasks can still execute when overdue. Changes: - Added `allowExpiredTasks` as an optional parameter in `lib.cron.new`.
|
Not really a suitable fix. @juddisjudd Do you think we can remove this check outright now? It was there to cover for some edge cases where jobs were incorrectly scheduled. |
I will take a look and see what would be best for this. |
|
@thelindat I think maybe this would be a better approach: if sleep < 0 then
if not self.maxDelay or -sleep > self.maxDelay then
return self:stop(self.debug and ('scheduled time expired %s seconds ago'):format(-sleep))
end
if self.debug then
print(('Task %s is delayed by %s seconds, executing now'):format(self.id, -sleep))
end
sleep = 0
endExample usage then setting something like this: |
|
Sure we can go with that, maybe default to 1 second. While we're at it, it would be good to swap to lib.print.debug and default debug to true if printLevel is set to debug. See #593 |
|
@st860923 would you like to update your PR with my suggestion or would you prefer that I do this? |
|
You can proceed with your suggested approach. Thank you! |
Introduces a new
allowExpiredTasksoption for cron jobs, allowing scheduled tasksto execute even if their scheduled time has already passed.
Previously, tasks that were slightly overdue (due to server hitches or thread
delays) were skipped, leading to inconsistencies in scheduling. With this change,
if
allowExpiredTasks = true, tasks can still execute when overdue.Changes:
allowExpiredTasksas an optional parameter inlib.cron.new.