cenkalti / kuyruk

⚙️ Simple task queue for Python
https://kuyruk.readthedocs.org/
MIT License
231 stars 17 forks source link

Kuyruk queue with variable name #76

Closed nathan30 closed 2 years ago

nathan30 commented 2 years ago

Hi,

I'm currently making a web app that can load different configuration based on the URL. I wonder if I can use Kuyruk to specify a queue for each instance.

For exemple for this URL : http://localhost/edissyum/dist/ --> each process I want to queue will use the task with queue id edissyum

The problem is, it could be edissyum or something else, it has to be dynamic, is there any solution I can imagine with Kuyruk ? Like declare my decorator and then change the queue name maybe ?

Thanks in advance

cenkalti commented 2 years ago

It is possible if you use send_to_queue method when sending tasks. It has host kwarg that gets appended to the queue name. This feature was designed to send the tasks that targeted for specific hosts (separate workers would be run on different queues on each host) but you can also use it to separate the work for each process.