rq-scheduler
rq-scheduler copied to clipboard
Periodic Job - Not respecting interval and repeat parameters
I set a code similar to the example in the README to be executed repeatedly. Interval=5 and repeat=10, but rq-scheduler is not executing jobs at this rate. Does anyone know how to solve this?
What rate is your scheduler executing the jobs at? I set the interval to 3600, hoping that it would execute once every hour, but it's actually executing multiple times per second.
Also having issues with scheduled jobs. I set interval to 3600 seconds but they're executed every 1m
Any solution to this? I am having the same issue specifically with interval - regardless of what I set it gets executed every 1m, although repeat seems to be working.
Im having the same issue @marpada . do yo have a solution for this?
Any update on this problem ?
@eclar #163 this might help.
@ryanermita Thanks, I understand better now.
Is this issue soled? I have set up 60sec scheduler refresh and task interval is one hour (interval=3600
), but the task gets scheduled every minute and sometimes even twice a minute :(
I can confirm that repeat
also gets ignored.
I've not seen this, so curious as to what's different about what you're doing...
I was trying to isolate the issue. I couldn't reproduce the issue. It might be something wrong with flask-rq2 integration with the scheduer....
It appears that decorator schedule create a scheduled task every time the flask app gets restarted. And you work in the development environment with reloading it happens often. I wonder if there is a way to control that. I tried with setting job_id. It resulted in the KeyError exception at the reloading.
Digging around I found that the working approach is to remove all scheduler jobs before setting up (https://stackoverflow.com/a/32033454/235362) schedule. With flask-rq2 it would be:
from . import tasks, rq
from datetime import datetime
def setup():
"""Set up the application schedule. Remove any already scheduled jobs."""
scheduler = rq.get_scheduler()
for job in scheduler.get_jobs():
job.delete()
# NB! add result_ttl! Otherwise it won't get rescheduled
tasks.my_task.schedule(datetime.utcnow(), interval=3600, result_ttl=-1, job_id="*MY-TASK*"))
does it continue to happen if you pass an explicit job id?
UPDATE! NB! it turned out that if result_ttl needs to be provided. Otherwise, it won't get rescheduled and will get removed from the list of the scheduled tasks. So to set up the scheduled task, use this snippet:
from . import tasks, rq
from datetime import datetime
def setup():
"""Set up the application schedule. Remove any already scheduled jobs."""
scheduler = rq.get_scheduler()
for job in scheduler.get_jobs():
job.delete()
tasks.my_task.schedule(datetime.utcnow(), interval=3600, result_ttl=-1, job_id="*MY-TASK*")
``
Any update on this issue? Seems to be an obvious problem, but it's been open for more than 2 years. This issue has been bugging my team a lot too.
using cron strings worked well for me