Django populate() isn't reentrant Django populate() isn't reentrant django django

Django populate() isn't reentrant


This RuntimeError first occured for me after upgrading to Django 1.7 (and still is present with Django 1.8). It is usually caused by an Django application which raises an error, but that error is swallowed somehow.

Here's a workaround which works for me. Add it to your wsgi.py and the real error should be logged:

import osimport timeimport tracebackimport signalimport sysfrom django.core.wsgi import get_wsgi_applicationtry:    application = get_wsgi_application()    print 'WSGI without exception'except Exception:    print 'handling WSGI exception'    # Error loading applications    if 'mod_wsgi' in sys.modules:        traceback.print_exc()        os.kill(os.getpid(), signal.SIGINT)        time.sleep(2.5)

See this thread on modwsgi for more details.


In the end the problem that I had was that I tried to run a second Django app and did not have the following defined in my apache config:

WSGIDaemonProcess ...WSGIProcessGroup ...

Just learned that you can run a single django app without defining them but when its two it produces a conflict.


There will be many reason to causes to populate() isn't reentrant error. If you look at the registry.py in your in django application probably inside this directory
/python2.7/site-packages/django/apps

        # app_config should be pristine, otherwise the code below won't        # guarantee that the order matches the order in INSTALLED_APPS.        if self.app_configs:            raise RuntimeError("populate() isn't reentrant")

As you see in the comment it says app_config should be pristine. Which means if one of configuration is not correct or required library missing it will rise this populate error. I got this error because I have missed sqlite installation. Even as you see there is no mentioning possible causes in the exception. I installed sqlite by this command on debian

pip install pysqlite

It solved my problem. My exception because of missing pysqlite.Your maybe having missing of another required packages or errors in your settings.py