首先,我正在使用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?
更多推荐
发布评论