Django funktioniert nicht mehr mit RuntimeError: populate () ist nicht wiedereintrittsfähig (

Ich habe eine Django-Webanwendung entwickelt, die auf einem Apache-Server mit WSGI bereitgestellt wurde, und alles lief reibungslos. Heute habe ich ein paar kleinere Änderungen an der @ meiner App vorgenommeadmin.py in einem Versuch, die eingebaute Django Admin-Oberfläche anzupassen, und machte anfangs einen Syntaxfehler (eine nicht geschlossene Klammer). Dies bedeutete, dass, als ich @ berührwsgi.py und lud den Code (auf meinem virtuellen Host wird WSGI im Dämonmodus ausgeführt). Meine Website wurde durch einen internen Serverfehler ersetzt, da WSGI beim Auftreten des Syntaxfehlers gestoppt wurde.

So habe ich den Syntaxfehler behoben, überprüft, dass ich mit @ keinen mehr hamanage.py check und berührtewsgi.py erneut bereitstellen. Auf meiner Website wird jedoch immer noch ein interner Serverfehler angezeigt! Beim Überprüfen der Apache-Protokolle sehe ich Folgendes:

[Sun Nov 23 13:52:46 2014] [info] mod_wsgi (pid=19093): Create interpreter 'quotes.cs.cornell.edu|'.
[Sun Nov 23 13:52:46 2014] [info] mod_wsgi (pid=19093): Adding '/extra/www/html/quotes/quotes_django' to path.
[Sun Nov 23 13:52:46 2014] [info] mod_wsgi (pid=19093): Adding '/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/' to path.
[Sun Nov 23 13:52:46 2014] [info] [client 128.84.33.19] mod_wsgi (pid=19093, process='quotes.cs.cornell.edu',
  application='quotes.cs.cornell.edu|'): Loading WSGI script '/extra/www/html/quotes/quotes_django/quotes_django/
wsgi.py'.
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] mod_wsgi (pid=19093): Target WSGI script '/extra/www/html/
quotes/quotes_django/quotes_django/wsgi.py' cannot be loaded as Python module.
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] mod_wsgi (pid=19093): Exception occurred processing WSGI
script '/extra/www/html/quotes/quotes_django/quotes_django/wsgi.py'.
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] Traceback (most recent call last):
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]   File "/extra/www/html/quotes/quotes_django/
quotes_django/wsgi.py", line 14, in <module>
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]     application = get_wsgi_application()
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]   File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]     django.setup()
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]   File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/__init__.py", line 21, in setup
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]     apps.populate(settings.INSTALLED_APPS)
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]   File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/apps/registry.py", line 115, in populate
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]     app_config.ready()
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]   File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/contrib/admin/apps.py", line 22, in ready
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]     self.module.autodiscover()
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]   File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/contrib/admin/__init__.py", line 23, in autodiscover
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]     autodiscover_modules('admin', register_to=site)
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]   File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/utils/module_loading.py", line 74, in autodiscover_modules
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]     import_module('%s.%s' % (app_config.name,         
module_to_search))
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]   File "/usr/lib64/python2.7/importlib/__init__.py", line 
37, in import_module
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]     __import__(name)
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]   File "/extra/www/html/quotes/quotes_django/quotespage/
admin.py", line 25
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]     approve_quotes.short_description = "Approve selected
quotes"
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19]                  ^
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] SyntaxError: invalid syntax
[Sun Nov 23 13:53:36 2014] [info] [client 128.84.33.19] mod_wsgi (pid=19093, process='quotes.cs.cornell.edu',
  application='quotes.cs.cornell.edu|'): Loading WSGI script '/extra/www/html/quotes/quotes_django/quotes_django/
wsgi.py'.
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] mod_wsgi (pid=19093): Target WSGI script '/extra/www/html/
quotes/quotes_django/quotes_django/wsgi.py' cannot be loaded as Python module.
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] mod_wsgi (pid=19093): Exception occurred processing WSGI
script '/extra/www/html/quotes/quotes_django/quotes_django/wsgi.py'.
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] Traceback (most recent call last):
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19]   File "/extra/www/html/quotes/quotes_django/         
quotes_django/wsgi.py", line 14, in <module>
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19]     application = get_wsgi_application()
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19]   File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19]     django.setup()
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19]   File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/__init__.py", line 21, in setup
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19]     apps.populate(settings.INSTALLED_APPS)
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19]   File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/apps/registry.py", line 78, in populate
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19]     raise RuntimeError("populate() isn't reentrant")
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] RuntimeError: populate() isn't reentrant

Die erste Fehlerserie zeigt, dass WSGI aufgrund des Syntaxfehlers in meinem @ fehlschlägadmin.py. Die zweite Reihe von Fehlern scheint jedoch einen internen Fehler von Django aufzuweisen:

RuntimeError: populate() isn't reentrant

aus dem @ geworfpopulate Methode vonregistry.py.

enn Sie diese Fehlermeldung googeln, erhalten Sie überraschend wenig Informationen, keine davon aus der Django-Dokumentation. Anscheinend kann es manchmal vorkommen, dass Sie eine App in Ihrem @ zweimal benennesettings.py, aber das mache ich nicht. Noch wichtiger ist, ich habe nicht @ geändesettings.py Seit dem Punkt, an dem die Website einwandfrei funktioniert hat - das einzige, was ich geändert habe, waradmin.py.

Ich habe versucht, alle vorgenommenen Änderungen rückgängig zu machen, sodass mein gesamter Python-Code wieder in dem Zustand ist, in dem die Website funktioniert hat - und ich erhalte immer noch daspopulate() isn't reentrant Fehler, wenn ich versuche, WSGI den Code neu laden zu lassen!

Ich habe auch versucht, verschiedene Apps im Abschnitt INSTALLED_APPS von @ auszukommentieresettings.py, und selbst wenn nur "django.contrib.staticfiles" aktiviert ist, tritt der Fehler immer noch auf. Komischerweise bekomme ich immer noch den Fehler, auch wenn ich @ auskommentieall the apps - Django wirft den Fehler auch dann, wenn keine Apps geladen werden!

Weiß jemand, was hier los ist? Oder eine bessere Möglichkeit für mich, diesen Fehler zu debuggen, da der Traceback im Apache-Protokoll ziemlich wenig hilfreich ist?

Notes: Ich verwende Django 1.7, Apache 2.2 und Python 2.7.

Antworten auf die Frage(54)

Ihre Antwort auf die Frage