Rq: Feature Request: Change order of jobs

Created on 7 May 2019  路  4Comments  路  Source: rq/rq

I couldn't find the option in the docs or in the source, but a feature to move a job in a queue would be great. In other words reorder the jobs, putting specific jobs above others. I know we can use higher priority queues etc., but I think the ability to move the job up or down the queue would also make a good feature. It could be done by popping all the jobs and re-adding them in the required order, but that just seems like it should be unnecessary. Is there any other way?

I'm happy to work on this, but I just wanted to double check it's not already possible and if you have any specific requirements or suggestions around this before I start. Thanks.

Most helpful comment

By default, enqueued jobs are processed on a FIFO basis.

You can use queue.enqueue(at_front=True) to put a job to the front most of the queue to be processed.

All 4 comments

No, it's not currently possible to reorder jobs. However, RQ supports job dependencies. This allows you to create foo_job that is only enqueued after bar_job executes successfully.

Reordering job also sounds like it will be an expensive operation on large queues.

Does this help?

A new kind of queue such as a priority queue might be useful in that situation.

Thanks for the replies. Looking at priority queues, that should work. I think it might also be possible using a FIFO queue if using a list, with the LINSERT Redis command. What queue type does RQ use currently - is it a FIFO/list or something else?

By default, enqueued jobs are processed on a FIFO basis.

You can use queue.enqueue(at_front=True) to put a job to the front most of the queue to be processed.

Was this page helpful?
0 / 5 - 0 ratings