Django / djcelery 1.8.2 AppRegistryNotReady: the translation infrastructure cannot be initialized

I get the following error:

File "/Library/Python/2.7/site-packages/Django-1.8.2-py2.7.egg/django/utils/translation/trans_real.py", line 164, in _add_installed_apps_translations "The translation infrastructure cannot be initialized before the " django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time. 

I have a project that is not really a django application, but a celery application. Therefore, I did not create wsgi.py or models.py or any of the typical files created by django-admin when starting a project or application.

I want to use djcelery to create periodic tasks using djcelery.schedules.DatabaseScheduler as described here Add, modify, delete celery.schedules at runtime and here How to dynamically add / remove periodic celery tasks (celerybeat)

The solution given here ( AppRegistryNotReady, translation error when deploying using uWSGI ) requires me to make changes to the vassal.ini file. In my implementation there is no vassal.ini file.

I will briefly describe my project -

 proj apps.py tasks.py celeryconfig.py runproj.py 
  • apps.py
  from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'celeryconfig') myapp = Celery('myapp') myapp.config_from_object('celeryconfig') if __name__ == '__main__' myapp.worker_main('-B', '-S', 'djcelery.schedules.DatabaseScheduler') 
  • tasks.py
  from apps import myapp @myapp.task(name='msgprinter') def msg_printer(msg): print msg 
  • runproj.py
  from djcelery.models import PeriodicTask, IntervalSchedule intSch = IntervalSchedule(period='seconds', every=30) periodic_task = PeriodicTask( name = 'msg_printer_schedule', task = 'proj.tasks.msg_printer', interval = intSch, args=json.dump(['such wow']), ) periodic_task.save() 
  • celeryconfig.py
  CELERY_ACCEPT_CONTENT = ['pickle', 'json'] BROKER_URL = 'amqp://guest@localhost' CELERY_IMPORTS = ('proj.tasks') CELERY_QUEUES = [Queue('default', Exchange('default', type='direct'), routing_key='default')] #DJANGO SETTINGS INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'djcelery', 'mypp') DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join('/home', 'test.db'), } } 

Before starting the workers, I created the necessary tables using the django-admin migrate command. I see tables in the /home/test.db database.

First I run the workers - $python apps.py Then I save the schedule for the database to be re-executed by the celerybeat daemons - $python runproj.py

+8
python django celery celerybeat djcelery
source share

No one has answered this question yet.

See similar questions:

163
Django 1.7 throws django.core.exceptions.AppRegistryNotReady: models not yet loaded
41
How to dynamically add / remove periodic celery tasks (celerybeat)
32
Django: AppRegistryNotReady ()
8
Add, modify, remove celery.schedules at run time

or similar:

29th
In celery 3.1, performing a django periodic task
7
Celery target lineup includes obsolete tasks
3
How to configure and run celerybeat
2
Djcelery is deprecated, but how to allow the user to add periodic jobs without it?
one
Celery beat up an old (deleted) task
0
Flask + Celery + Redis: consumer: cannot connect to amqp: // guest: **@127.0.0.1: 5672 //: timeout
0
Celery, AttributeError: the 'module' object does not have the 'celeryconfig' attribute
0
Celery periodic quests not starting
0
How to formulate a function for a Django Celery task

All Articles