Skip to content
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

Schedulers taking longer than defined for execution #221

Open
jangster3794 opened this issue Jan 6, 2020 · 3 comments
Open

Schedulers taking longer than defined for execution #221

jangster3794 opened this issue Jan 6, 2020 · 3 comments

Comments

@jangster3794
Copy link

def schedule_task(func, delaytime=1, *args,**kwargs): enqueue_time = datetime.utcnow() + timedelta(seconds=delaytime) scheduler.enqueue_at(enqueue_time, delay_queue_handler, func, *args,**kwargs)

This is how I am trying to schedule my task. However, it takes more than 25-30 seconds before it sends my task to the worker.

What can I do to fix this?

Or if I am not approaching this well, please let me know

This is how my scheduler is initializing

scheduler = Scheduler('default',connection=redis_conn)

@spetoolio
Copy link

The scheduler only queues job on a certain interval. If your enqueue_time falls between intervals, it will not be added to the queue until the next interval (which will then be picked up by your worker). Look at https://github.com/rq/rq-scheduler#running-the-scheduler - specifically about the interval.

This may be what you're experiencing.

@jangster3794
Copy link
Author

@dfrank8 Hi, Thanks for replying. Can you please tell me the default interval?
By what you have explained, I think this is exactly what's happening because if I have queued some tasks, all of them execute at the same time.

@spetoolio
Copy link

A quick look at the docs shows the default interval is 60.

https://github.com/rq/rq-scheduler/blob/master/rq_scheduler/scheduler.py#L26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants