So this one was doozy. I use a workaround, but just put this in case there is a better solution. And after spending a few hours to figure it out, I also do it as prey.
Basically, I was wondering if there are smart ways to avoid recursive calls to django.setup ().
I have 3 or 4 batch scripts that can be run offline or from celery. One of them is called build_profiles.py
How celery gets them (in one of the tasks.py files):
from pssecurity.batch.build_profiles import \ ProfileManager as MgrCls_profiles, \ getOptParser as getOptParser_profiles
In Django 1.6, this scheme worked just fine (I'm not completely convinced that celery is the best way to run potentially autonomous processes, but that's a different story).
When I tried to run build_profiles.py from the command line, it gave the AppRegistryNotReady error.
No problem, I thought, add the following to the top of build_profiles.py, according to https://docs.djangoproject.com/en/dev/ref/applications/#applications-troubleshooting
import django django.setup()
And then nothing worked with Django. single tests were not performed, maintaining the manager.py server. How can I go to an autonomous party to stop my system?
It turns out that django.setup () detects a celery that loads its tasks, and if one of them finishes executing its own django.setup () ...
source share