Ticket #19593: 0001-Adds-flushing-of-stdout-and-stderr-after-writes.patch

File 0001-Adds-flushing-of-stdout-and-stderr-after-writes.patch, 1.8 KB (added by chroto24@…, 12 years ago)
  • django/core/management/commands/runserver.py

    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):  
    8989        quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
    9090
    9191        self.stdout.write("Validating models...\n\n")
     92        self.stdout.flush()
    9293        self.validate(display_num_errors=True)
    9394        self.stdout.write((
    9495            "%(started_at)s\n"
    class Command(BaseCommand):  
    103104            "port": self.port,
    104105            "quit_command": quit_command,
    105106        })
     107        self.stdout.flush()
    106108        # django.core.management.base forces the locale to en-us. We should
    107109        # set it up correctly for the first request (particularly important
    108110        # in the "--noreload" case).
    class Command(BaseCommand):  
    124126            except (AttributeError, KeyError):
    125127                error_text = str(e)
    126128            self.stderr.write("Error: %s" % error_text)
     129            self.stderr.flush()
    127130            # Need to use an OS exit because sys.exit doesn't work in a thread
    128131            os._exit(1)
    129132        except KeyboardInterrupt:
Back to Top