Django가 RuntimeError로 작동하지 않습니다 .Pulate () is n't reentrant
WSGI를 사용하여 Apache 서버에 배포 된 Django 웹 애플리케이션을 개발해 왔으며 모든 것이 순조롭게 진행되었습니다. 오늘 저는 내장 admin.py
Django Admin 인터페이스를 사용자 지정하기 위해 내 앱을 약간 변경 했으며 처음에는 구문 오류 (닫히지 않은 괄호)를 만들었습니다. 즉 wsgi.py
, 코드를 터치 하고로드 할 때 (내 가상 호스트에서 데몬 모드에서 WSGI를 실행하고 있음) 내 웹 사이트가 구문 오류가 발생하면 WSGI가 중지 되었기 때문에 내부 서버 오류로 대체되었습니다.
나는 구문 오류를 고정 그래서, 나는 더 이상으로하지 않았 음을 확인 manage.py check
하고, 감동을 wsgi.py
다시 배포. 하지만 내 웹 사이트에 여전히 내부 서버 오류가 표시됩니다! Apache 로그를 확인하면 다음과 같습니다.
[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
첫 번째 일련의 오류는 내 .NET의 구문 오류로 인해 WSGI가 실패했음을 보여줍니다 admin.py
. 그러나 두 번째 일련의 오류는 Django 내부 오류를 표시하는 것 같습니다.
RuntimeError: populate() isn't reentrant
의 populate
메소드 에서 던져졌습니다 registry.py
.
이 오류 메시지를 인터넷 검색하면 놀랍게도 거의 정보가 반환되지 않으며 Django 문서에서는 제공되지 않습니다. 분명히에서 앱의 이름을 두 번 지정하면 때때로 발생할 수 settings.py
있지만 나는 그렇게하지 않습니다. 더 중요한 것은 settings.py
웹 사이트가 잘 작동했던 시점 이후로 변경 한 적이 없다는 것 admin.py
입니다.
내가 만든 모든 변경 사항을 되돌리려 고했기 때문에 모든 Python 코드가 웹 사이트가 작동 중일 때의 상태로 돌아 왔고 populate() isn't reentrant
WSGI에서 코드를 다시로드하려고하면 여전히 오류가 발생합니다!
또한의 INSTALLED_APPS 섹션에서 다른 앱을 주석 처리하려고 시도했으며 settings.py
'django.contrib.staticfiles'만 활성화해도 오류가 계속 발생합니다. 이상하게도 모든 앱을 주석 처리해도 여전히 오류가 발생 합니다 . Django는 앱을로드하지 않아도 오류가 발생합니다!
여기에서 무슨 일이 일어나고 있는지 아는 사람이 있습니까? 아니면 아파치 로그의 트레이스 백이 도움이되지 않기 때문에이 오류를 디버깅하는 더 좋은 방법이 있습니까?
참고 : Django 1.7, Apache 2.2 및 Python 2.7을 사용하고 있습니다.
내 서버의 관리자가 Apache를 다시 시작했고이 문제가 마법처럼 해결되었습니다. 정확히 동일한 Python 파일이 populate() isn't reentrant
. 구문 오류가있는 다른 파일을로드 한 다음 수정하려고했는데 서버가 새 파일을로드하고 문제없이 올바르게 실행할 수있었습니다.
나는 아직도 무엇이 잘못되었는지 모르겠지만 문제가 사라졌기 때문에 이것을 답변으로 표시하고 있습니다. (글쎄, StackOverflow가 내 답변을 수락 할 수있게하자마자 답변 됨으로 표시하겠습니다.)
업데이트 : 실수로 구문 오류가있는 Python을 업로드 할 때이 오류가 계속 발생한 후 Apache를 다시 시작하는 것보다 쉬운 해결 방법을 찾았습니다. WSGI가 populate() isn't reentrant
오류를 던지기 시작하면 Django 프로젝트 wsgi.py
를 다음과 같은 간단한 함수로 바꿉니다 .
def application(environ, start_response):
if environ['mod_wsgi.process_group'] != '':
import signal
os.kill(os.getpid(), signal.SIGINT)
return ["killed"]
그런 다음 웹 사이트를 다시로드하면 WSGI 데몬 프로세스가 다시 시작됩니다 (웹 사이트에 여전히 동일한 500 오류가 표시 되더라도 Apache 로그를 보면 알 수 있음).
그런 다음 wsgi.py
다시 정상으로 변경 하고 다시로드하면 WSGI는 던지지 않고 코드를 성공적으로 선택합니다 populate() isn't reentrant
(이번에는 구문 오류가 없다고 가정). 따라서 Apache 전체를 다시 시작할 필요가없고 WSGI 프로세스 만 있으면 루트 권한 없이도이를 수행 할 수 있습니다.
나는 이것이 오래된 대답이라는 것을 알고 있지만 내 솔루션에 기여할 것입니다.
문제의 원인을 진단하고 manage.py check
거기에서 찾은 것이 있는지 확인하는 방법으로
제 경우에는 오래된 요구 사항이 문제 였고 django가 하위 모듈을 가져 오지 못했습니다.
요구 사항이 최신 상태인지 확인
이것은 Django 설정 어딘가의 버그로 인해 발생합니다. 불행히도 Django는이 일반적이고 쓸모없는 오류 메시지 뒤에 버그를 숨기고 있습니다.
실제 문제를 나타내려면 django/apps/registry.py
80 행을 열고 주위를 바꾸십시오.
raise RuntimeError("populate() isn't reentrant")
와:
self.app_configs = {}
이렇게하면 Django가 계속로드되고 실제 오류가 표시됩니다.
여러 가지 원인으로이 오류가 발생했습니다. 한 번은 내 앱의 admin.py 중 하나에 잘못된 가져 오기가 있었기 때문입니다.
Google App Engine을 사용할 때이 오류가 발생하면 로그에서 원인이 될 수있는 다른 오류를 확인하세요. 나는 얻고 있었다 :
ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3
Google App Engine과 함께 SQLite를 사용할 수 없으므로 해당 오류와 오류 DATABASES
를 settings.py
중지하는 섹션을 주석 처리하십시오 RuntimeError("populate() isn't reentrant")
.
로딩 프로세스의 초기에있는 파일 (wsgi.py 제외)을 터치하여 Apache를 다시 시작하지 않고도 수정할 수 있습니다. 예를 들어, 설정 파일 :
$ touch settings.py
나는 이것을 제대로 해결하지 못했지만 여기 내 질문에 더 많은 정보가 있습니다 .mod-wsgi의 Django 1.7에서 코드 변경 모니터링이 오작동합니다.
반응이 아니라 반영입니다.
django 1.7로 업그레이드 할 때 500 오류가 발생하고 페이지를 다시로드하면 Apache는 "populate ()가 재진입이 아닙니다"라고 말합니다. 페이지를로드 할 때 Apache가 앱에 필요한 모든 모듈을로드하고 오류가 처리되면 모듈을 언로드하지 않습니다. 따라서 페이지를 다시로드 할 때 아파치는 이러한 모듈을 다시로드하지만 이미로드되었습니다. 따라서 아파치는 "populate ()가 재진입이 아닙니다"라고 말합니다.
이 문제를 해결하기 위해 두 가지 조치가 있습니다. 아파치를 다시 시작하거나 첫 번째 5OO 오류를 처리하는 오류를 수정합니다.
다음을 사용하여 아파치를 다시 시작하십시오.
sudo service httpd restart
도움이 되길 바랍니다.
이것은 동일한 Apache mod-wsgi 오류에 대한 유효한 응답 모음처럼 보이며 각 사람이 자신을 위해 작동하는 것을 게시하므로 여기에 내 것입니다.
배포 후 프로젝트 요구 사항을 업데이트하는 것을 잊지 마십시오. :)
Apache는 wsgi 파일을 캐시에 저장합니다. Python 파일의 Apache 캐싱 비활성화
따라서 먼저 wsgi 파일을 삭제하고 acpache를 다시 시작한 다음 wsgi 파일을 다시 추가하고 apache를 다시 시작하십시오.
나는이 같은 문제를 경험했고, 나에게 오류의 원인은 내가 작업하던 파일의 구문 오류 일 뿐이었다. 오타를 수정 한 후 populate() is not reentrant
오류가 사라졌습니다.
wsgi 스크립트에서 django를 실행하는 경우 명령 줄에서 wsgi 스크립트를 실행하여 오타를 식별 할 수 있습니다. 예를 들면 :
cd /usr/local/www/wsgi-scripts/
python djangolauncher.wsgi
이 오류는 코드에서 공백과 탭이 일치하지 않는 경우에도 생성됩니다.
나는 방금 같은 문제에 직면하여 주변을 둘러보기 시작했습니다.
이제 작동하게되었으므로 여러분과 공유해야한다고 생각했습니다!
모든 내가 그랬어 할 수 있었다 chown user:group /to/path -R
그리고 chmod 770 /to/path -R
다시 한번 그것은했다.
설정 : Ubuntu 14.04, Django 1.10, Python 3.5 (in virtualenv
).
운없이 이러한 솔루션을 많이 시도했지만 Apache 오류 로그에 두 가지 다른 오류가 포함되어 있음을 알았습니다. 누군가가 페이지를 방문하려고 할 때 발생하는 것이고 다른 하나는 시작할 때 발생합니다. 일반적으로 페이지를 몇 번 새로 고치려고 시도하여 방문 오류가 몇 번만 반복되는 것을 보았 기 때문에 시작을 놓쳤습니다.
그런 다음 대신 시작 오류에 대한 해결책을 찾았고이 질문에 대한 해결책 이 저에게 효과적이었습니다 . 간단히 말해서 mod_wsgi
원형 교차로 방식으로 패키지를 업데이트하는 것입니다.
mod_wsgi
버전 불일치에 대한 경고를 몇 달 동안 받았지만 갑자기 Apache 오류 500이 발생했습니다. 나에게 말이 안 돼.
My guess is that this RuntimeError: populate() isn't reentrant
error is usually a sign that one should look for a startup error, which indicates the real problem.
on visit
[Sat Oct 15 03:38:08.900966 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] mod_wsgi (pid=28272): Target WSGI script '/django/GP/GP/wsgi.py' cannot be loaded as Python module.
[Sat Oct 15 03:38:08.901409 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] mod_wsgi (pid=28272): Exception occurred processing WSGI script '/django/GP/GP/wsgi.py'.
[Sat Oct 15 03:38:08.901662 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] Traceback (most recent call last):
[Sat Oct 15 03:38:08.902184 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/GP/GP/wsgi.py", line 16, in <module>
[Sat Oct 15 03:38:08.902217 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] application = get_wsgi_application()
[Sat Oct 15 03:38:08.902501 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Sat Oct 15 03:38:08.902529 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] django.setup(set_prefix=False)
[Sat Oct 15 03:38:08.902726 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
[Sat Oct 15 03:38:08.902755 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] apps.populate(settings.INSTALLED_APPS)
[Sat Oct 15 03:38:08.902924 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/apps/registry.py", line 78, in populate
[Sat Oct 15 03:38:08.902953 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] raise RuntimeError("populate() isn't reentrant")
[Sat Oct 15 03:38:08.903111 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] RuntimeError: populate() isn't reentrant
start up
[Sat Oct 15 03:38:08.900966 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] mod_wsgi (pid=28272): Target WSGI script '/django/GP/GP/wsgi.py' cannot be loaded as Python module.
[Sat Oct 15 03:38:08.901409 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] mod_wsgi (pid=28272): Exception occurred processing WSGI script '/django/GP/GP/wsgi.py'.
[Sat Oct 15 03:38:08.901662 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] Traceback (most recent call last):
[Sat Oct 15 03:38:08.902184 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/GP/GP/wsgi.py", line 16, in <module>
[Sat Oct 15 03:38:08.902217 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] application = get_wsgi_application()
[Sat Oct 15 03:38:08.902501 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Sat Oct 15 03:38:08.902529 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] django.setup(set_prefix=False)
[Sat Oct 15 03:38:08.902726 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
[Sat Oct 15 03:38:08.902755 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] apps.populate(settings.INSTALLED_APPS)
[Sat Oct 15 03:38:08.902924 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/apps/registry.py", line 78, in populate
[Sat Oct 15 03:38:08.902953 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] raise RuntimeError("populate() isn't reentrant")
[Sat Oct 15 03:38:08.903111 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] RuntimeError: populate() isn't reentrant
[Sat Oct 15 03:38:43.291502 2016] [:error] [pid 28272] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Sat Oct 15 03:38:43.291579 2016] [:error] [pid 28272] Traceback (most recent call last):
[Sat Oct 15 03:38:43.291604 2016] [:error] [pid 28272] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Sat Oct 15 03:38:43.292356 2016] [:error] [pid 28272] assert tlock is not None
[Sat Oct 15 03:38:43.292377 2016] [:error] [pid 28272] AssertionError:
[Fri Oct 14 23:38:43.412942 2016] [:error] [pid 28299] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.413044 2016] [:error] [pid 28299] Traceback (most recent call last):
[Fri Oct 14 23:38:43.413076 2016] [:error] [pid 28299] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.425037 2016] [:error] [pid 28275] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.425125 2016] [:error] [pid 28275] Traceback (most recent call last):
[Fri Oct 14 23:38:43.425157 2016] [:error] [pid 28275] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.427625 2016] [:error] [pid 28274] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.427694 2016] [:error] [pid 28274] Traceback (most recent call last):
[Fri Oct 14 23:38:43.427722 2016] [:error] [pid 28274] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.432020 2016] [:error] [pid 28273] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.432078 2016] [:error] [pid 28273] Traceback (most recent call last):
[Fri Oct 14 23:38:43.432105 2016] [:error] [pid 28273] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.438577 2016] [:error] [pid 28299] assert tlock is not None
[Fri Oct 14 23:38:43.438654 2016] [:error] [pid 28299] AssertionError:
[Fri Oct 14 23:38:43.442174 2016] [:error] [pid 28274] assert tlock is not None
[Fri Oct 14 23:38:43.442226 2016] [:error] [pid 28274] AssertionError:
[Fri Oct 14 23:38:43.447227 2016] [:error] [pid 28276] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.447294 2016] [:error] [pid 28276] Traceback (most recent call last):
[Fri Oct 14 23:38:43.447326 2016] [:error] [pid 28276] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.448813 2016] [:error] [pid 28277] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.448876 2016] [:error] [pid 28277] Traceback (most recent call last):
[Fri Oct 14 23:38:43.448903 2016] [:error] [pid 28277] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.450188 2016] [:error] [pid 28273] assert tlock is not None
[Fri Oct 14 23:38:43.450231 2016] [:error] [pid 28273] AssertionError:
[Fri Oct 14 23:38:43.456680 2016] [:error] [pid 28275] assert tlock is not None
[Fri Oct 14 23:38:43.456737 2016] [:error] [pid 28275] AssertionError:
[Fri Oct 14 23:38:43.461761 2016] [:error] [pid 28277] assert tlock is not None
[Fri Oct 14 23:38:43.461826 2016] [:error] [pid 28277] AssertionError:
[Fri Oct 14 23:38:43.466165 2016] [:error] [pid 28276] assert tlock is not None
[Fri Oct 14 23:38:43.466219 2016] [:error] [pid 28276] AssertionError:
[Fri Oct 14 23:38:43.658971 2016] [mpm_prefork:notice] [pid 28268] AH00169: caught SIGTERM, shutting down
[Sat Oct 15 03:38:43.691909 2016] [:error] [pid 28272] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Sat Oct 15 03:38:43.691968 2016] [:error] [pid 28272] Traceback (most recent call last):
[Sat Oct 15 03:38:43.691996 2016] [:error] [pid 28272] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Sat Oct 15 03:38:43.693126 2016] [:error] [pid 28272] assert tlock is not None
[Sat Oct 15 03:38:43.693159 2016] [:error] [pid 28272] AssertionError:
[Fri Oct 14 23:38:44.490316 2016] [:warn] [pid 28349] mod_wsgi: Compiled for Python/3.4.0.
[Fri Oct 14 23:38:44.490407 2016] [:warn] [pid 28349] mod_wsgi: Runtime using Python/3.4.3.
[Fri Oct 14 23:38:44.505672 2016] [mpm_prefork:notice] [pid 28349] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.19 mod_wsgi/3.4 Python/3.4.3 configured -- resuming normal operations
[Fri Oct 14 23:38:44.505764 2016] [core:notice] [pid 28349] AH00094: Command line: '/usr/sbin/apache2'
I know it has been a while since this question was asked, but I just ran into this issue due to a problem I haven't seen discussed here. I was getting the RuntimeError: populate() isn't reentrant
error due to SELinux on CentOS 7. I had Django served out of a home directory, and I simply had to enable the SELinux boolean that allowed reading home directories, as the populate() error was due to a permissions issue. The solution for me was setsebool -P httpd_read_user_content 1
. I hope this helps someone having this issue.
The multitude of answers makes it clear; this is a generic error that can have multiple root causes, typically related to loading Apache/WSGI.
All of these answers on this page should function as a kind of checklist, and in that vein I want to add the root cause of my instance of this error: failure to add an 'import os' to your settings.py file.
Specifically, we had a developer on our team who intended to remove an unneeded package, and instead removed 'import os' from the top of the production settings.py file. After an apache restart, our application wouldn't restart and we received the dreaded 'RuntimeError: populate() isn't reentrant' error.
A quick 'python manage.py check' did not reveal the issue, but a 'python settings.py' did; the os package was not loaded.
If you have this error, focus your search on checking your settings.py file(s) and also your WSGI file.
I had this problem and couldn't find any answer why until I backtracked my commits. Apparently I had added an accidental import, because of auto-completion, that screwed up the setup.
# found in models.py from msilib.schema import SelfReg
In apache error log: RuntimeError("populate() isn't reentrant")
It worked fine in my windows dev environment but failed on the ubuntu/apache server.
I was going into this same error after having change the order of this setting :
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
putting it back on the order here before and restarting apache fixed the issue.
In my case, I had a custom renderer class
for Django Rest Framework
, for some purpose I had to override the renderer class's method "get_context" (full disclosure : to make django toolbar
give correct SQL query count)
I removed that class and redeployed. It Worked.
In my case the error occured because a required pip-package was missing.
So I did a pip install -r requirements.txt
, restarted apache and things worked again.
Removing the virtualenv directory, recreating the virtualenv, then reinstalling all the requirements fixed it for me.
RuntimeError: populate() isn't reentrant
Can be anything, that is why there are so many different answers for this question.
The trick is to look at the error message just before the RuntimeError
. In your case there seems to be a syntax error in the file /extra/www/htmlquotes/quotes_django/quotespage/admin.py on line 15, see:
Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/extra/www/htmlquotes/quotes_django/quotespage/admin.py", line 25
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] pprove_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
Adding my reason to the list. For me it was because I had a django service named with the same directory as a process directory. Renaming the process/dir fixed the issue.
I had a recursive django.setup()
, eg I tried to write a django.setup()
inside a an app/models.py
, in the stack trace django tried to point this out near:
... "site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
...
... ./myproject/myapp/models.py ...
so yeah, be sure not to try to setup django while django is being setup...
Restarting the Apache server for me solved the problem. You can do that by using the command $ sudo service apache2 restart
Note on AWS Elastic Beanstalk: The default settings.py
that is written by Django-admin includes a reference to a local sqlite database as the data source. This will likely work on your local OS, but not on AWS EB, and will give the populate() isn't reentrant
runtime error. To test for this, simply comment out the DATABASES={<...>}
statement in settings.py
, deploy, and re-open the application.
I had this same issue, what worked for me was commenting out the default database settings in / settings.py . I also read that later versions of django are not compatible with ebs
In my case, I had a circular import, which cause an error that break the populate method.
I solved problem with adding __init__.py
to my apps folder.
touch /mainprojectfolder/projectfolderwhichcontainswsgi.py/apps/__init__.py
Then it worked!
To throw in my 2 Euro cents:
I recreated a working setup in Docker. The new Docker setup failed with
populate isn't reentrant
which seems to be a generic error. In my case, I overlooked that
pip install Django
installs the latest version (2.0
), instead of the required version 1.11
. Changing this to
pip install Django==1.11
fixed my problem.
I think this is a generic error when something is wrong with settings.py
. Sometimes I can find the problem by trial and error by removing the installed apps one at a time. In some cases, its not related to the installed apps. But from my experience, in all cases its a problem within the settings.py
file.
check if you have mentioned your api names twice in the settings.py ' s installed app section.
Application definition
INSTALLED_APPS = [
...
'rest_framework',
'myapp_api',
'myapp_api.apps.myappWebserviceApiConfig',
]
Application definition
INSTALLED_APPS = [
...
'rest_framework',
'myapp_api.apps.myappWebserviceApiConfig',
]
Removing duplicate entries solved my problem
'developer tip' 카테고리의 다른 글
VBA의 해시 테이블 / 연관 배열 (0) | 2020.09.12 |
---|---|
Scala에서 하위 배열을 얻는 올바른 방법은 무엇입니까? (0) | 2020.09.12 |
리턴을 사용할 때 스위치를 중단해야합니까? (0) | 2020.09.12 |
C # : 정적 메서드가 여러 스레드에서 호출되면 어떻게됩니까? (0) | 2020.09.12 |
WinForms의 Model-View-Presenter (0) | 2020.09.12 |