Django停止打印到stdout(Django stops printing to stdout)

编程入门 行业动态 更新时间:2024-10-26 09:19:47
Django停止打印到stdout(Django stops printing to stdout)

首先,我正在使用Windows,只是为了说清楚。 我使用cmd.exe来manage runserver ,服务器运行正常。 然而,有时,在看似随机的基础上,Django只是停止写入stdout! 服务器响应我的请求和所有内容,但没有任何内容被打印出来。

为了使它更清晰,我甚至不在谈论我的Django代码中的print ,所以这不是问题。 我正在谈论它打印时,例如GET /someurl HTTP/1.1 ,yada-yada ...按Ctrl + Break并重新启动服务器没有帮助。 但是,如果我退出命令提示符并启动一个新命令并在该服务器中运行服务器,它将再次开始工作。

关于发生了什么的任何想法? 这是Django 1.0.2 final和Python 2.6.2。

First of all, I'm using Windows, just to make that clear. I am using cmd.exe to manage runserver and the server runs just fine. However, sometimes, on a seemingly random basis, Django simply stops writing to stdout! The server responds to my requests and everything, but nothing gets printed.

To make it even clearer, I'm not even talking about print in my Django code, so that cannot be the problem. I'm talking about when it prints e.g. GET /someurl HTTP/1.1, yada-yada... Hitting Ctrl+Break and restarting the server doesn't help. However, if I exit the command prompt and start a new one and run the server in that one, it starts working again.

Any ideas about what's going on? This is with Django 1.0.2 final and Python 2.6.2.

最满意答案

也许有点拉伸,但在Linux 2.6下使用Twisted框架(而不是Django),我有这种行为发生在我的应用程序向stdout发送NULL并且stdout被重定向到syslog的任何时候。 我原以为这是扭曲框架的syslog实现中的一个错误,但也许更多。 你可以从日志记录或客户端活动中告诉你在丢失标准输出之前最后做了什么,看看它是否a)总是在少数几个地方之一和2)如果你当时发送任何有趣的东西?

Maybe a bit of a stretch,but under Python 2.6 under Linux using the Twisted framework (instead of Django), I had this behaviour occur anytime my application sent a NULL to stdout and stdout was redirected to syslog. I had assumed this was a bug in the twisted framework's syslog implementation, but maybe its something more. Can you tell from either logging or client activity what the last thing it was doing before losing stdout and see if it is a) always in one of a handful of places and 2) if you are sending anything funky out at the time?

更多推荐

本文发布于:2023-04-29 09:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335973.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:stdout   Django   printing   stops

发布评论

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

>www.elefans.com

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