rq icon indicating copy to clipboard operation
rq copied to clipboard

Detect duplicate jobs

Open acjay opened this issue 11 years ago • 9 comments

Besides manually maintaining a list outside of RQ someplace, is there a good built in way to ensure that a job isn't queued while an identical job is still waiting to be processed?

acjay avatar Apr 15 '13 23:04 acjay

There's a branch containing a job Registry class that maintains a list of enqueued jobs (and their functions). Once this is merged in, we'll be able to do:

if func in queue:
    # Do something

selwin avatar Apr 16 '13 01:04 selwin

Will that check with parameters? For my purposes, I'd want to check the combination of the function and all arguments.

acjay avatar Apr 16 '13 07:04 acjay

Not at the moment. You'd have to extend it by getting all jobs having that function (a cheap operation) and checking for their arguments (may be expensive depending on the number of jobs you have).

selwin avatar Apr 16 '13 09:04 selwin

@selwin As said before, it could be nice to have that as well:

if (func, (3,), {}) in queue:
    # Do something

Under the hood, you could do the loop you're suggesting.

nvie avatar Apr 19 '13 11:04 nvie

That would be brilliant!

acjay avatar Apr 23 '13 14:04 acjay

We could use job.get_call_string() instead of just job.func_name in the code that @selwin suggested, to achieve that. Isn't it?

asldevi avatar Sep 27 '13 09:09 asldevi

what is the status of this deduplication? Is it in the current version of RQ?

VidJa avatar Jan 12 '18 14:01 VidJa

@VidJa this feature is not yet implemented. This is something I look forward to tackling when I have the time. The first step would be to build a mapping of the types of enqueued jobs - this will be very useful for monitoring

selwin avatar Jan 16 '18 04:01 selwin

Any updates on this?

luisdavim avatar Nov 08 '23 19:11 luisdavim