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

Multiple Queues (v.0.16) #126

Closed
tsutsarin opened this issue May 8, 2019 · 7 comments · Fixed by #127
Closed

Multiple Queues (v.0.16) #126

tsutsarin opened this issue May 8, 2019 · 7 comments · Fixed by #127

Comments

@tsutsarin
Copy link
Contributor

How I'm supposed to create multiple queues with arq v0.16?

Looking at old docs I see that you could specify queue name, but now you can't.
What was the purpose of deleting queues from API?

I tried to start workers with different functions, but if worker doesn't see registered function it just deletes job.

So, if I want to use multiple queues on the same redis instance I have to use multiple redis databases (that have only numerical names)?

@samuelcolvin
Copy link
Owner

What was the purpose of deleting queues from API?

arq was completely redesigned to use sorted sets rather than lists to allow deferred calling and proper retry on failure/cancellation. Removing separate queues was just a bi-product of that.

The short answer is that arq v0.16 doesn't do multiple queues because I don't find them useful.

If you have a job that's higher priority than others, call it with a negative _defer_by and it'll run before other jobs enqueued at the same time, for example:

  • if you enqueued a job with _defer_by=timedelta(minutes=-1) it would run before other jobs enqueued in the last minite
  • if you enqueued a job with _defer_by=timedelta(days=-1) it would run before all jobs enqueued in the last year, in other words immediately that there's a slot available to run the job.

By doing this you can get most of the functionality of different priority jobs.

Does that help?

@tsutsarin
Copy link
Contributor Author

My use case is to run different queues, which are tasks for unrelated workers, not to sort them by priority.
(But that info was useful anyway)

@tsutsarin
Copy link
Contributor Author

Also, redis cluster doesn't support multiple databases, so separating queues using them won't work.

Redis Cluster does not support multiple databases like the stand alone version of Redis. There is just database 0 and the SELECT command is not allowed.
https://redis.io/topics/cluster-spec

@samuelcolvin
Copy link
Owner

It shouldn't be very hard to add custom queue names, so you'd use something like

await redis.enqueue_job('download_content', url, _queue_name='other')

and then setup the worker to work on that queue. Worker's would still only process jobs from one queue, but it sounds like that would work in your use case?

If that works, PR welcome.

@tsutsarin
Copy link
Contributor Author

What will be your guidance to implement this feature?

@samuelcolvin
Copy link
Owner

I'm not sure what you mean?

If you'd like the feature, I'd happily accept a pull request where you implement it.

@Minstel
Copy link

Minstel commented Aug 22, 2021

@samuelcolvin

if you enqueued a job with _defer_by=timedelta(days=-1) it would run before all jobs enqueued in the last year, in other words immediately that there's a slot available to run the job.

Do you mean enqueued in the last day instead of year?

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

Successfully merging a pull request may close this issue.

3 participants