My __init__.py file
from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app
__all__ = ('celery_app',)
My celery.py file
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
app = Celery('myproject')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
my /etc/supervisor/conf.d/celery.conf file:
[program:]
command=/home/user/venv/bin/celery -A myproject worker --loglevel=INFO
environment=PYTHONPATH=/home/user/project-folder
user=user
numprocs=1
autostart=true
autorestart=true
stdout_logfile=/home/user/logs/celery.log
stderr_logfile=/home/user/logs/celery.log
startssecs=10
stopwaitsecs = 600
stopasgroup=true
priority=100
and this is the last section of the error message in celery.log
File "/home/user/venv/lib/python3.6/site-packages/celery/loaders/base.py", line 131, in config_from_object
self._conf = force_mapping(obj)
File "/home/user/venv/lib/python3.6/site-packages/celery/utils/collections.py", line 48, in force_mapping
return DictAttribute(m) if not isinstance(m, Mapping) else m
File "/home/user/venv/lib/python3.6/abc.py", line 183, in __instancecheck__
subclass = instance.__class__
File "/home/user/venv/lib/python3.6/site- packages/django/utils/functional.py", line 215, in inner
self._setup()
File "/home/user/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/home/user/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/user/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 894, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
File "<frozen importlib._bootstrap_external>", line 1129, in _get_spec
File "<frozen importlib._bootstrap_external>", line 1273, in find_spec
File "<frozen importlib._bootstrap_external>", line 1231, in _get_spec
File "<frozen importlib._bootstrap_external>", line 556, in
spec_from_file_location
RecursionError: maximum recursion depth exceeded
I don't know whats wrong with this configuration?
supervisorto start thegunicornandceleryin two separateconffiles. Gunicorn runs well but my celery workers don't. The command to start the celery workers is the first line in mycelery.conffilegunicorn.conffile. When I runsudo supervisorctl rereadand thensudo supervisorctl updatethe gunicorn daemon is run first, and then it fails with celery.conf, with the above message