Why can't it find my celery config file?
Now in Celery 4.1 you can solve that problem by that code(the easiest way):
import celeryconfigfrom celery import Celeryapp = Celery()app.config_from_object(celeryconfig)
For Example small celeryconfig.py :
BROKER_URL = 'pyamqp://'CELERY_RESULT_BACKEND = 'redis://localhost'CELERY_ROUTES = {'task_name': {'queue': 'queue_name_for_task'}}
Also very simple way:
from celery import Celeryapp = Celery('tasks')app.conf.update( result_expires=60, task_acks_late=True, broker_url='pyamqp://', result_backend='redis://localhost')
Or Using a configuration class/object:
from celery import Celeryapp = Celery()class Config: enable_utc = True timezone = 'Europe/London'app.config_from_object(Config)# or using the fully qualified name of the object:# app.config_from_object('module:Config')
Or how was mentioned by setting CELERY_CONFIG_MODULE
import osfrom celery import Celery#: Set default configuration module nameos.environ.setdefault('CELERY_CONFIG_MODULE', 'celeryconfig')app = Celery()app.config_from_envvar('CELERY_CONFIG_MODULE')
Also see:
- Create config: http://docs.celeryproject.org/en/latest/userguide/application.html#configuration
- Configuration fields: http://docs.celeryproject.org/en/latest/userguide/configuration.html