How to keep multiple independent celery queues?

后端 未结 2 1523
不思量自难忘°
不思量自难忘° 2020-12-07 20:34

I\'m trying to keep multiple celery queues with different tasks and workers in the same redis database. Really just a convenience issue of only wanting one redis server rath

2条回答
  •  遥遥无期
    2020-12-07 21:18

    By default everything goes into a default queue named celery (and this is what celery worker will process if no queue is specified)

    So say you have your do_work task function in django_project_root/myapp/tasks.py.

    You could configure the do_work task to live in it's own queue like so:

    CELERY_ROUTES = {
        'myproject.tasks.do_work': {'queue': 'red'},
    }
    

    Then run a worker using celery worker -Q red and it will only process things in that queue (another worker invoked with celery worker will only pickup things in the default queue)

    The task routing section in the documentation should explain all.

提交回复
热议问题