tags:

views:

158

answers:

4

Hi

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.

A: 

Do you assign something to sys.stdout or sys.stderr at some point in your code?

Steef
No, I'm quite convinced that this never happens.
Deniz Dogan
A: 

The development server can act weird sometimes, just stop it with ctrl-break then start it again.

One thing you can try, just to be sure that the server itself didn't stop, is do a hard-refresh (ctrl-F5), if it doesn't respond, then the server is actually dead, and you were just seeing the cached version of the page.

hasen j
What's weird is that even though I Ctrl+Break and restart the server, it still won't output anything. No requests are printed, only "Validating models, 0 errors found" and then the version and that I can quit by hitting Ctrl+Break. I always Ctrl+F5 to make sure I reload everything and in Firebug I can see that it is indeed doing so.
Deniz Dogan
A: 

This may seem stupid, but did you check the log files? Also, you could make a lot of requests from urllib, or whatever web client you want, and try to reproduce that. Maybe you'll see a pattern as to why this happens.

Geo
What log files? I was not aware of any log files. Or are you referring to my own custom logging functionality? Because I don't have that and I would really not like to dive into that because of what seems like a bug.
Deniz Dogan
i think what he means is that django keeps log files
Rasiel
I was under the impression django had a log file, like Rails has. If this isn't true, you should implement your own logging functionality.
Geo
A: 

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?

bdk
This actually doesn't happen anymore, so it's difficult for me to reproduce it... However, I think your answer was nice, so here, have 150! :)
Deniz Dogan