Privacy Policy
Snippets index

  Insulate Multiple celery workers for multiple Django apps on the same machine

# at the end of settings.py
project_name = "name_of_your_project"
from kombu import Exchange, Queue
CELERY_QUEUES = (
    Queue(
        project_name,
        Exchange(project_name),
        routing_key=project_name
    ),
)

You can then start your celry worker as such

celery -n project_name -A project_name worker -Q project_name

This will ensure that each celery worker is only listening on the queue for each project. This should solve your problem

You can also have the celery workers on the same server at the same time and they can also listen on the same redis host without conflicting each other.

Note that -n project_name is necessary:

You can start multiple workers on the same machine, but be sure to name each
individual worker by specifying a node name with the --hostname argument