[celery] How to run different multiple workers using different queue
If you are going to run multiple workers and got some key error when doing async job in celery like (KeyError, Received unregistered task of type).
This would be a solution.
Key statement
"Use different Queue name and run worker with that Queue name". reference
0. Structure
folder/ tasks/ some_tasks.py the_other_tasks.py scheduler.py |
1. scheduler.py
# import from tasks.some_tasks import sum # use queue name, when you call task function |
2. tasks
A. some_tasks.py
app = Celery(..) |
B. the_other_tasks.py
app = Celery(..) app.conf.task_default_queue = "the_other_tasks" |
*If you want to give name to worker, use -n option.
example) celery -A tasks.the_other_tasks worker --loglevel=info --concurrency=1 -n the_other_tasks -Q the_other_tasks