调试模式下的 Django 管道损坏

编程入门 行业动态 更新时间:2024-10-09 00:39:42
本文介绍了调试模式下的 Django 管道损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在 Nginx 后面的远程服务器上安装了 django 1.3.

I have django 1.3 on the remote server behind Nginx.

如果我使用 apache + mod_wsgi 运行 django,我可以查看 apache 日志文件中的错误.没关系,但我想在控制台中使用.

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.

如果我运行 django 自己的开发服务器,只有当 DEBUG = False 时,我才会在控制台中收到堆栈跟踪错误.在调试模式控制台输出

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

我想弄清楚为什么?为什么 django 只是输出未命名的异常?为什么它依赖于 DEBUG 变量.

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.

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

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 指令 proxy_intercept_errors off;(默认禁用)正是我需要的

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

更多推荐

调试模式下的 Django 管道损坏

本文发布于:2023-11-23 22:12:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623001.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:管道   模式下   Django

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!