Code

Opened 18 months ago

Closed 18 months ago

Last modified 17 months 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: master
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@… 18 months ago.

Download all attachments as: .zip

Change History (5)

comment:1 follow-up: Changed 18 months ago by akaariai

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 18 months ago by akaariai

  • Resolution set to wontfix
  • Status changed from new to closed

Whoops, didn't mean to accept...

comment:3 in reply to: ↑ 1 Changed 17 months ago by lemuelf

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 17 months ago by lemuelf (previous) (diff)

comment:4 Changed 17 months ago by lemuelf

  • Cc lemuelf@… added

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.