From e476de7dc375db936800b2c60689d26b31abdf11 Mon Sep 17 00:00:00 2001
From: Chris Proto <cproto@fusionbox.com>
Date: Thu, 10 Jan 2013 12:08:31 -0700
Subject: [PATCH] Adds flushing of stdout and stderr after writes
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.
---
django/core/management/commands/runserver.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
index 391e0b4..d735b06 100644
a
|
b
|
class Command(BaseCommand):
|
89 | 89 | quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C' |
90 | 90 | |
91 | 91 | self.stdout.write("Validating models...\n\n") |
| 92 | self.stdout.flush() |
92 | 93 | self.validate(display_num_errors=True) |
93 | 94 | self.stdout.write(( |
94 | 95 | "%(started_at)s\n" |
… |
… |
class Command(BaseCommand):
|
103 | 104 | "port": self.port, |
104 | 105 | "quit_command": quit_command, |
105 | 106 | }) |
| 107 | self.stdout.flush() |
106 | 108 | # django.core.management.base forces the locale to en-us. We should |
107 | 109 | # set it up correctly for the first request (particularly important |
108 | 110 | # in the "--noreload" case). |
… |
… |
class Command(BaseCommand):
|
124 | 126 | except (AttributeError, KeyError): |
125 | 127 | error_text = str(e) |
126 | 128 | self.stderr.write("Error: %s" % error_text) |
| 129 | self.stderr.flush() |
127 | 130 | # Need to use an OS exit because sys.exit doesn't work in a thread |
128 | 131 | os._exit(1) |
129 | 132 | except KeyboardInterrupt: |