Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't it find my celery config file?

Tags:

/home/myuser/mysite-env/lib/python2.6/site-packages/celery/loaders/default.py:53: NotConfigured: No celeryconfig.py module found! Please make sure it exists and is available to Python.
NotConfigured)

I even defined it in my /etc/profile and also in my virtual environment's "activate". But it's not reading it.

like image 676
TIMEX Avatar asked Jan 21 '11 19:01

TIMEX


People also ask

Where is celery config file?

Celery documentation says that the configuration file should be in the working directory or in python path. Here config_file is /opt/celery/celery_config.py . The idea is to give user the freedom to create config file. The documentation says that config file should either be in working directory or in sys path.

What are celery workers?

What is a Celery worker? ​ Celery is a task management system that you can use to distribute tasks across different machines or threads. It allows you to have a task queue and can schedule and process tasks in real-time. This task queue is monitored by workers which constantly look for new work to perform.


1 Answers

Now in Celery 4.1 you can solve that problem by that code(the easiest way):

import celeryconfig  from celery import Celery  app = 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 Celery  app = 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 Celery  app = 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 os from celery import Celery  #: Set default configuration module name os.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
like image 185
Sergey Luchko Avatar answered Oct 01 '22 11:10

Sergey Luchko