I have a django 2.0.5 app using celery==4.2.1, redis==2.10.6, redis-server=4.0.9. When I start celery worker, I get this output:
-------------- celery@octopus v4.2.1 (windowlicker)
---- **** -----
--- * *** * -- Linux-4.18.16-surface-linux-surface-x86_64-with-Ubuntu-18.04-bionic 2018-10-31 17:33:50
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: MemorabiliaJSON:0x7fd6c537b240
- ** ---------- .> transport: amqp://guest:**@localhost:5672//
- ** ---------- .> results: disabled://
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
But in my django settings I have:
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_IMPORTS = ('memorabilia.tasks',
'face_recognition.tasks',
)
My celery.py looks like:
# http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from django.apps import apps
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MemorabiliaJSON.settings.tsunami')
app = Celery('MemorabiliaJSON')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks(lambda: [n.name for n in apps.get_app_configs()])
The same code (shared through my git server) works on my development machine, although the redis server is a bit older – v=2.8.4. The development machine is Ubunut 14.04, and the laptop is Ubuntu 18.04. By works, I mean this is the celery output on my development machine:
-------------- celery@tsunami v4.2.1 (windowlicker)
---- **** -----
--- * *** * -- Linux-4.4.0-138-generic-x86_64-with-Ubuntu-14.04-trusty 2018-10-31 17:38:09
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: MemorabiliaJSON:0x7f356e024c18
- ** ---------- .> transport: redis://localhost:6379//
- ** ---------- .> results: redis://localhost:6379/
- *** --- * --- .> concurrency: 8 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
How do I get celery to read the django config file other than what I have in celery.py?
Thanks!
Mark
Best Answer
changing
localhost
to127.0.0.1
solved the problem in my case :