cenkalti / kuyruk

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

Weird behavior with two Kuyruk workers #70

Closed nathan30 closed 4 years ago

nathan30 commented 4 years ago

Hi, On my project I created two worker. On the main.py, I have the @OCforInvoices.task decorator On the main_splitter.py I have the @OCforInvoices_Sep.task decorator

When I launch a process using main.py, is the OCforInvoices worker is busy, it will use OCforInvoices_Sep and vice versa. Is that normal ?

How could I avoid that ?

nathan30 commented 4 years ago

If needed, you could see both of the files, here : https://gitlab.com/edissyum/opencapture/opencaptureforinvoices/-/tree/master/bin/src

cenkalti commented 4 years ago

I see that both tasks are sent the default queue. You can separate them by providing a queue name in task decorator.

In main.py change:

@OCforInvoices.task(queue='invoices')
def launch(args):

If you do this, tasks will be sent to a queue named invoices. Then you can run a worker that consumes from that queue:

$ kuyruk --app bin.src.main.OCforInvoices worker --queue invoices

You can give a different queue name in your other main_splitter.py file.

nathan30 commented 4 years ago

Oh I see, thanks a lot !