Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19593 closed New feature (wontfix)

Add flushing of stdout and stderr for the `manage.py runserver` management command

Reported by: chroto24@… Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: lemuelf@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Because output is written without ever closing the fds until sys.exit is
called after a KeyboardInterrupt exception, it is difficult to read
stdin or stdout from a parent process that may spawn a development
server subprocess.

https://groups.google.com/forum/?fromgroups=#!topic/django-developers/0c7M08Zr27g

Attachments (1)

0001-Adds-flushing-of-stdout-and-stderr-after-writes.patch (1.8 KB ) - added by chroto24@… 12 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Anssi Kääriäinen, 12 years ago

Triage Stage: UnreviewedAccepted

I am going to wontfix this - you can open the subprocess with 'python -u' if needed which should give the semantics wanted.

If this isn't possible to do for some reason, then lets reconsider. In that case I think we should then make self.stdout and self.stderr unbuffered by default for all management commands.

An useful stackoverflow link: http://stackoverflow.com/questions/881696/unbuffered-stdout-in-python-as-in-python-u-from-within-the-program

comment:2 by Anssi Kääriäinen, 12 years ago

Resolution: wontfix
Status: newclosed

Whoops, didn't mean to accept...

in reply to:  1 comment:3 by Lemuel Formacil, 12 years ago

Replying to akaariai:

I am going to wontfix this - you can open the subprocess with 'python -u' if needed which should give the semantics wanted.

Hi, akaariai.

Just a note: (a long one :-)

If I do:

$ python -u manage.py runserver

it spawns child python process without the -u switch:

$ pgrep -fl python
11968 python -u manage.py runserver
11972 /Users/lemuelf/.virtualenvs/online_store/bin/python manage.py runserver

And if I try to directly run the child-most process, e.g.:

$ /Users/lemuelf/.virtualenvs/online_store/bin/python -u manage.py runserver

it still spawns a child python process without the -u switch:

$ pgrep -fL python
10390 /Users/lemuelf/.virtualenvs/online_store/bin/python -u manage.py runserver
10393 /Users/lemuelf/.virtualenvs/online_store/bin/python manage.py runserver

However, I find that setting the PYTHONUNBUFFERED env var works, like the following:

$ PYTHONUNBUFFERED=1 python manage.py runserver

Still wontfix? PYTHONUNBUFFERED=1 is too unwieldy :-)

Last edited 12 years ago by Lemuel Formacil (previous) (diff)

comment:4 by Lemuel Formacil, 12 years ago

Cc: lemuelf@… added
Note: See TracTickets for help on using tickets.
Back to Top