runserver stdout and stderr piping problems

Showing 1-4 of 4 messages
runserver stdout and stderr piping problems JuhaS 1/20/12 12:04 PM
I was launching manage.py runserver from another app and trying to
capture the output correctly without luck using pipes. Eventually I
narrowed the problem down to two issues. In my opinion they are bugs
but I thought I'd ask for confirmations here before creating a ticket
and patch.

Issue 1: The startup message of development server isn't flushed.

The result is that starting the server from console directly it is
printed correctly during startup, but using pipes the message isn't
flushed until shutdown (Ctrl+C pressed). Since log messages use etderr
(issue 2) they are flushed before the startup message.

Example:

$ python manage.py runserver 2>> output 1>> output  // redirect stderr
and stdout to file named output

[send few http requests]
[press Ctrl+C]

$ cat output

[20/Jan/2012 13:54:24] "GET // HTTP/1.1" 200 358
[20/Jan/2012 13:54:24] "GET // HTTP/1.1" 200 358
[20/Jan/2012 13:54:24] "GET // HTTP/1.1" 200 358
Validating models...

0 errors found
Django version 1.4 alpha 1, using settings 'djangotut.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Since the actual log messages go to stderr (next issue), the startup
message keeps hanging until shotdown when it's eventually printed to
end of the file. I tried with many commands and all showed the same
issue.

Is this a clear bug?

SOLUTION: adding a stdout.flush() to runserver.py fixes this for me.


Issue 2: Log entries about http requests go to stderr

For some reason the log entries go to stderr (for example 'GET //
HTTP...'). Is this a bug, or is there some reason for this?
Re: runserver stdout and stderr piping problems Russell Keith-Magee 1/9/13 5:50 PM

I'm not aware of a ticket for this issue, and I couldn't find one from a quick search, so feel free to open one. The approach described by the OP seems reasonable, so if you want to provide a patch as well, feel free.

Yours,
Russ Magee %-)

On Wed, Jan 9, 2013 at 11:37 PM, Chris Proto <chro...@gmail.com> wrote:
Did you ever get around to opening a ticket for this?  If so, what is the status?
--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/GgVXCHG1e2QJ.

To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.

Re: runserver stdout and stderr piping problems Chris Proto 1/10/13 11:56 AM
Re: runserver stdout and stderr piping problems Chris Proto 1/10/13 12:00 PM
It doesn't look like it responded to this topic when I sent a reply with email.

Anyway, I opened up a ticket  https://code.djangoproject.com/ticket/19593