Django在调试模式下破坏管道 [英] Django Broken pipe in Debug mode

查看:157
本文介绍了Django在调试模式下破坏管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



如果我运行django自己的开发服务器,那么在控制台中只有当DEBUG = False时才会收到stacktrace错误。在DEBUG模式控制台输出中

 在(...,...)处理请求期间发生异常
追溯(最近的电话最后):
文件/usr/local/python/lib/python2.7/SocketServer.py,第284行,在_handle_request_noblock
self.process_request(request,client_address)
文件/usr/local/python/lib/python2.7/SocketServer.py,第310行,process_request
self.finish_request(request,client_address)
文件/ usr / local / python / lib / python2.7 / SocketServer.py,第323行,在finish_request
self.RequestHandlerClass(request,client_address,self)
文件/usr/local/python/lib/python2.7 /site-packages/django/core/servers/basehttp.py,第570行,__init__
BaseHTTPRequestHandler .__ init __(self,* args,** kwargs)
文件/ usr / local / python /lib/python2.7/SocketServer.py,第641行,__init__
self.finish()
文件/usr/local/python/lib/python2.7/SocketServer.py,线694,完成
sel f.wfile.flush()
文件/usr/local/python/lib/python2.7/socket.py,第301行,flush
self._sock.sendall(view [write_offset: write_offset + buffer_size])
错误:[Errno 32] Broken pipe

为什么?为什么django只是输出未命名的异常?为什么这取决于DEBUG变量。



当我无法访问请求对象时,这种错误大多发生在外部视图之外。所以我无法在中间件或使用日志处理程序中捕获它。



更新。我注意到,如果我直接请求django服务器,我从来没有得到Broken管道。那么可能问题发生在Nginx代理django?

解决方案

Nginx指令 proxy_intercept_errors off; (默认禁用)是什么我需要


I have django 1.3 on the remote server behind Nginx.

If I run django with apache + mod_wsgi, I can watch errors in apache log files. It's ok but I'd like to have in console.

If I run django own development server, I get errors with stacktrace in console only when DEBUG = False. In DEBUG mode console outputs

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

I want to figure out why? Why does django just output unnamed Exception? Why does it depend on DEBUG variable.

This errors occurs mostly outside views when I have no access to request object. So I can't catch it in middleware or using logging handler.

UPDATE. I noticed if I request to django server directly I never get Broken pipe. So may the issue occur while Nginx proxy django?

解决方案

Nginx directive proxy_intercept_errors off; (disabled by default) is what I needed

这篇关于Django在调试模式下破坏管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆