#19593 closed New feature (wontfix)
Add flushing of stdout and stderr for the `manage.py runserver` management command
Reported by: | 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)
Change History (5)
by , 12 years ago
Attachment: | 0001-Adds-flushing-of-stdout-and-stderr-after-writes.patch added |
---|
follow-up: 3 comment:1 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Whoops, didn't mean to accept...
comment:3 by , 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 :-)
comment:4 by , 12 years ago
Cc: | added |
---|
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