Django在调试模式下损坏的管道

我在Nginx后面的远程服务器上有django 1.3。

如果我用apache + mod_wsgi运行django,我可以在apache日志文件中观察错误。可以,但我想在控制台中使用。

如果运行django自己的开发服务器,则仅当DEBUG = False时,控制台中的stacktrace才会出现错误。在调试模式下,控制台输出

Exception happened during processing of request from (..., ...)

Traceback (most recent call last):

File "/usr/local/python/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock

self.process_request(request, client_address)

File "/usr/local/python/lib/python2.7/SocketServer.py", line 310, in process_request

self.finish_request(request, client_address)

File "/usr/local/python/lib/python2.7/SocketServer.py", line 323, in finish_request

self.RequestHandlerClass(request, client_address, self)

File "/usr/local/python/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 570, in __init__

BaseHTTPRequestHandler.__init__(self, *args, **kwargs)

File "/usr/local/python/lib/python2.7/SocketServer.py", line 641, in __init__

self.finish()

File "/usr/local/python/lib/python2.7/SocketServer.py", line 694, in finish

self.wfile.flush()

File "/usr/local/python/lib/python2.7/socket.py", line 301, in flush

self._sock.sendall(view[write_offset:write_offset+buffer_size])

error: [Errno 32] Broken pipe

我想弄清楚为什么?django为什么只输出未命名的Exception?为什么它取决于DEBUG变量。

当我无权访问请求对象时,此错误通常发生在外部视图中。因此,我无法在中间件或日志记录处理程序中捕获它。

更新。我注意到如果我直接请求django服务器,我永远也不会遇到断管问题。那么Nginx代理django可能会出现问题吗?

回答:

proxy_intercept_errors off;我需要Nginx指令(默认情况下禁用)

以上是 Django在调试模式下损坏的管道 的全部内容, 来源链接: utcz.com/qa/414465.html

回到顶部