-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strategies for Repeating Execution of Periodic Tasks #47
Comments
A few thoughts here:
This would provide building blocks where you could combine (1) and (2) if you need more fine-grained control over execution. I could maybe even make a smaller cut by providing the timestamp it was scheduled for allowing you to run or not from the worker code itself. I'd need to pull the run timestamp from redis to impl (1) which I'm not yet doing but it's simple to add. If I'm doing that, maybe it's easier to just pass it down on the Job struct. Either way, these are good suggestions! |
Thank you for your quick reply.
The current approach is that the execution of the previous and next tasks are not related. After getting the periodical tasks that meet the conditions from the Redis, they are directly pushed into the task queue.
|
I was just wondering if having a generic middleware to prevent unbounded job duration would be helpful. This is something anyone can write today for themselves but if there was a need to bundle one with the crate, we can. Let's say out of scope for this ticket.
With the current Job struct you cannot see the expected execution time (or the schedule itself like you can with APS). However, I can push this information through so you can see it and write something for your use case. Btw, this sounds like what I've used unique jobs for (https://github.com/sidekiq/sidekiq/wiki/Ent-Unique-Jobs) in the past. You can have a cron job run once a minute and then have a For example, you could build a poor man's middleware uniqueness lock, even only having it target a
That won't prevent the jobs from being inserted in the first place. Sidekiq ruby has a client middleware that makes doing stuff like this a little bit easier, but it will work if you're only looking to limit periodic jobs if another job is already running. |
Thank you for your quick response. |
Hello,
I would like to inquire about the repeating execution of periodic tasks:
Assuming I have a scheduled task that runs every 10 seconds. Under normal circumstances, the task completes within the 10-second interval, which works well.
However, in certain situations where the task exceeds the 10-second limit and the subsequent task is set to start, the current implementation appears to allow the ongoing task to continue execution.
At such times, it is often necessary to just skip the execution or implement alternative strategies.
I think the coalesce and misfire_grace_time parameters of Python APScheduler may provide a good insight.
APScheduler
The text was updated successfully, but these errors were encountered: