从iOS设备上传Django中的图片时,“标题:wsgi.py之前的脚本输出结束”

时间:2013-12-17 01:18:17

标签: django apache afnetworking mod-wsgi django-wsgi

出于某种原因,有时当我的用户上传图片时,我会一直收到500错误,我无法自行复制。我在django / apache / wsgi日志中唯一能看到的是:

[core:error] [pid 17191]标题前的脚本输出结束:wsgi.py

我不知道从哪里开始...

编辑#1

我将LogLevel更改为Debug,我得到以下内容:

[Tue Dec 17 14:11:46.600635 2013] [proxy:debug] [pid 29456] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.600709 2013] [proxy:debug] [pid 29456] proxy_util.c(1785): AH00931: initialized single connection worker in child 29456 for (*)
[Tue Dec 17 14:11:46.600788 2013] [:info] [pid 29456] mod_wsgi (pid=29456): Initializing Python.
[Tue Dec 17 14:11:46.608906 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Starting process 'poka' with uid=48, gid=48 and threads=15.
[Tue Dec 17 14:11:46.609425 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Initializing Python.
[Tue Dec 17 14:11:46.612573 2013] [proxy:debug] [pid 29457] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Tue Dec 17 14:11:46.612627 2013] [proxy:debug] [pid 29457] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.612698 2013] [proxy:debug] [pid 29457] proxy_util.c(1785): AH00931: initialized single connection worker in child 29457 for (*)
[Tue Dec 17 14:11:46.612779 2013] [:info] [pid 29457] mod_wsgi (pid=29457): Initializing Python.
[Tue Dec 17 14:11:46.616459 2013] [proxy:debug] [pid 29458] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Tue Dec 17 14:11:46.616511 2013] [proxy:debug] [pid 29458] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.616574 2013] [proxy:debug] [pid 29458] proxy_util.c(1785): AH00931: initialized single connection worker in child 29458 for (*)
[Tue Dec 17 14:11:46.616644 2013] [:info] [pid 29458] mod_wsgi (pid=29458): Initializing Python.
[Tue Dec 17 14:11:46.630974 2013] [proxy:debug] [pid 29459] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Tue Dec 17 14:11:46.631046 2013] [proxy:debug] [pid 29459] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.631116 2013] [proxy:debug] [pid 29459] proxy_util.c(1785): AH00931: initialized single connection worker in child 29459 for (*)
[Tue Dec 17 14:11:46.631195 2013] [:info] [pid 29459] mod_wsgi (pid=29459): Initializing Python.
[Tue Dec 17 14:11:46.664817 2013] [mpm_prefork:notice] [pid 29453] AH00163: Apache/2.4.6 (Amazon) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Tue Dec 17 14:11:46.664879 2013] [mpm_prefork:info] [pid 29453] AH00164: Server built: Sep 20 2013 18:01:06
[Tue Dec 17 14:11:46.664901 2013] [core:notice] [pid 29453] AH00094: Command line: '/usr/sbin/httpd'
[Tue Dec 17 14:11:46.664939 2013] [mpm_prefork:debug] [pid 29453] prefork.c(995): AH00165: Accept mutex: sysvsem (default: sysvsem)
[Tue Dec 17 14:11:46.668668 2013] [proxy:debug] [pid 29460] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Tue Dec 17 14:11:46.668748 2013] [proxy:debug] [pid 29460] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.668832 2013] [proxy:debug] [pid 29460] proxy_util.c(1785): AH00931: initialized single connection worker in child 29460 for (*)
[Tue Dec 17 14:11:46.668921 2013] [:info] [pid 29460] mod_wsgi (pid=29460): Initializing Python.
[Tue Dec 17 14:11:46.685523 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Attach interpreter ''.
[Tue Dec 17 14:11:46.685687 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Adding '/srv/www/poka/app/poka' to path.
[Tue Dec 17 14:11:46.685955 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Adding '/srv/www/poka/app/env/main/lib/python2.7/site-packages' to path.
[Tue Dec 17 14:11:46.694283 2013] [:info] [pid 29458] mod_wsgi (pid=29458): Attach interpreter ''.
[Tue Dec 17 14:11:46.695044 2013] [:info] [pid 29456] mod_wsgi (pid=29456): Attach interpreter ''.
[Tue Dec 17 14:11:46.698253 2013] [:info] [pid 29457] mod_wsgi (pid=29457): Attach interpreter ''.
[Tue Dec 17 14:11:46.702979 2013] [:info] [pid 29459] mod_wsgi (pid=29459): Attach interpreter ''.
[Tue Dec 17 14:11:46.711173 2013] [:info] [pid 29460] mod_wsgi (pid=29460): Attach interpreter ''.

编辑#2 我的wsgi.py

"""

This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.

Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.

"""
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.prod")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
import djcelery
from django.core.wsgi import get_wsgi_application
djcelery.setup_loader()
_application = get_wsgi_application()

env_variables_to_pass = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY']

def application(environ, start_response):
    # pass the WSGI environment variables on through to os.environ
    for var in env_variables_to_pass:
        os.environ[var] = environ.get(var, '')
    return _application(environ, start_response)

编辑#3 :记录来自logs / error_log

[Thu Dec 19 18:05:58.247406 2013] [auth_digest:notice] [pid 1733] AH01757: generating secret for digest authentication ...
[Thu Dec 19 18:05:58.248882 2013] [lbmethod_heartbeat:notice] [pid 1733] AH02282: No slotmem from mod_heartmonitor
[Thu Dec 19 18:05:58.300894 2013] [ssl:warn] [pid 1733] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Dec 19 18:05:58.591912 2013] [mpm_prefork:notice] [pid 1733] AH00163: Apache/2.4.6 (Amazon) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Thu Dec 19 18:05:58.591987 2013] [core:notice] [pid 1733] AH00094: Command line: '/usr/sbin/httpd'
[Thu Dec 19 18:06:09.626354 2013] [core:notice] [pid 1733] AH00052: child pid 1735 exit signal Segmentation fault (11)
[Thu Dec 19 19:31:42.719739 2013] [:error] [pid 1755] (70007)The timeout specified has expired: [client 96.33.249.142:49830] mod_wsgi (pid=1755): Unable to get bucket brigade for request.
[Thu Dec 19 19:31:43.195999 2013] [:error] [pid 1769] [client 96.33.249.142:29054] mod_wsgi (pid=1769): Exception occurred processing WSGI script '/srv/www/poka/app/poka/apache/wsgi.py'.
[Thu Dec 19 19:31:43.196140 2013] [:error] [pid 1769] [client 96.33.249.142:29054] IOError: failed to write data

1 个答案:

答案 0 :(得分:1)

当我遇到此错误时,原因是我通过帖子发送多部分数据,并通过将<form method="POST">更改为<form method="POST" enctype="multipart/form-data">来修复此问题