Django的 - 脚本输出结束前的头 [英] Django - End of script output before headers
问题描述
基本 hello.wsgi
工作正常。其他Django应用也完美的作品,绝对相同的virtualenv版本。
Basic hello.wsgi
works fine. Other django application also works perfect with absolutely the same virtualenv version.
的mod_wsgi
挂起〜10分钟(!),我看没有什么可以指出我的问题(日志级别调试):
mod_wsgi
hangs for ~10 min (!!!), and i see nothing can point me a problem (loglevel debug):
[Tue Mar 25 23:11:08.878578 2014] [:info] [pid 4719:tid 140720591648640] mod_wsgi (pid=4719): Attach interpreter ''.
[Tue Mar 25 23:11:08.879171 2014] [:info] [pid 4717:tid 140720591648640] mod_wsgi (pid=4717): Attach interpreter ''.
[Tue Mar 25 23:11:10.891348 2014] [authz_core:debug] [pid 4730:tid 140720477226752] mod_authz_core.c(802): [client 127.0.0.1:40844] AH01626: authorization result of Require all granted: granted
[Tue Mar 25 23:11:10.891391 2014] [authz_core:debug] [pid 4730:tid 140720477226752] mod_authz_core.c(802): [client 127.0.0.1:40844] AH01626: authorization result of <RequireAny>: granted
[Tue Mar 25 23:11:10.891489 2014] [authz_core:debug] [pid 4730:tid 140720477226752] mod_authz_core.c(802): [client 127.0.0.1:40844] AH01626: authorization result of Require all granted: granted
[Tue Mar 25 23:11:10.891497 2014] [authz_core:debug] [pid 4730:tid 140720477226752] mod_authz_core.c(802): [client 127.0.0.1:40844] AH01626: authorization result of <RequireAny>: granted
[Tue Mar 25 23:11:10.903921 2014] [:info] [pid 4719:tid 140720469034752] mod_wsgi (pid=4719): Create interpreter 'prj-dev|'.
[Tue Mar 25 23:11:10.905378 2014] [:info] [pid 4719:tid 140720469034752] [remote 127.0.0.1:57616] mod_wsgi (pid=4719, process='prj.project-dev', application='prj-dev|'): Loading WSGI script '/var/www/prj.project-dev/venv/www/public/index.wsgi'.
[Tue Mar 25 23:11:12.014799 2014] [:error] [pid 4719:tid 140720469034752] /usr/lib/python2.7/dist-packages/numpy/oldnumeric/__init__.py:11: ModuleDeprecationWarning: The oldnumeric module will be dropped in Numpy 1.9
[Tue Mar 25 23:11:12.014843 2014] [:error] [pid 4719:tid 140720469034752] warnings.warn(_msg, ModuleDeprecationWarning)
[Tue Mar 25 23:11:12.014846 2014] [:error] [pid 4719:tid 140720469034752]
[Tue Mar 25 23:16:11.888631 2014] [:info] [pid 4719:tid 140720485820160] mod_wsgi (pid=4719): Daemon process deadlock timer expired, stopping process 'prj.project-dev'.
[Tue Mar 25 23:16:11.888761 2014] [:info] [pid 4719:tid 140720591648640] mod_wsgi (pid=4719): Shutdown requested 'prj.project-dev'.
[Tue Mar 25 23:16:16.889065 2014] [:info] [pid 4719:tid 140720121513728] mod_wsgi (pid=4719): Aborting process 'prj.project-dev'.
[Tue Mar 25 23:16:16.895499 2014] [core:error] [pid 4730:tid 140720477226752] [client 127.0.0.1:40844] End of script output before headers: index.wsgi
[Tue Mar 25 23:16:17.160980 2014] [:info] [pid 5295:tid 140720591648640] mod_wsgi (pid=5295): Attach interpreter ''.
Apache的配置也包含什么有趣的。同样的配置适用其他服务器上。
Apache config also contains nothing interesting. The same configuration works on other server.
<VirtualHost *:80>
ServerName prj-dev
ServerAdmin admin@force.fm
DocumentRoot "/var/www/prj.project-dev/venv/www/public"
ErrorLog /var/log/apache2/prj.project-dev/error_log
CustomLog /var/log/apache2/prj.project-dev/access_log common
Alias /media/ /var/www/prj.project-dev/venv/prj/prj/media/
Alias /static/ /var/www/prj.project-dev/venv/prj/prj/static/
Alias /usermedia/ /var/www/prj.project-dev/venv/prj/prj/usermedia/
<Directory /var/www/prj.project-dev/venv/prj/prj/usermedia>
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/prj.project-dev/venv/prj/prj/media>
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/prj.project-dev/venv/prj/prj/static>
Order deny,allow
Allow from all
</Directory>
WSGIDaemonProcess prj.project-dev user=user group=user processes=2 threads=2 display-name=%{GROUP}
WSGIProcessGroup prj.project-dev
WSGIScriptAlias / /var/www/prj.project-dev/venv/www/public/index.wsgi
XSendFile on
<Directory /var/www/prj.project-dev/venv/www/public>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
没有什么有趣的 WSGI
:
import os, sys
activate_this = '/var/www/prj.project-dev/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
sys.path = [
'/var/www/prj.project-dev/venv/lib/python2.7/site-packages/',
'/var/www/prj.project-dev/venv/prj/',
'/var/www/prj.project-dev/venv/',
] + sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'prj.settings'
import django.core.handlers.wsgi
#from raven.contrib.django.middleware.wsgi import Sentry
application = django.core.handlers.wsgi.WSGIHandler()
#application = Sentry(django.core.handlers.wsgi.WSGIHandler())
我的问题是:我怎样才能得到它挂起的真正原因。
My question is: how can i get the real reason it hangs?
推荐答案
这是由mod_wsgi的文件覆盖。
This is covered by the mod_wsgi documentation.
<一个href=\"http://$c$c.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API\">http://$c$c.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API
总之,你有可能使用未实施在Python子间preTER正常工作,一个Python扩展模块。操作的阻塞操作时或扩展模块未正确释放GIL。这两种可能会导致跨preTER僵局。
In short, you are likely using a Python extension module which is not implemented to work properly in a Python sub interpreter. That or the extension module is not releasing the GIL properly when doing blocking operations. Both can result in an interpreter deadlock.
使用该解决方案的文档,看看是否有帮助。
Use the solution in the documentation and see if that helps.
这篇关于Django的 - 脚本输出结束前的头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!