[issue14000] Subprocess stdin.flush does not flush

Andrew Moffat report at bugs.python.org
Mon Feb 13 10:54:09 CET 2012

New submission from Andrew Moffat <andrew.robert.moffat at gmail.com>:

The following code only works if the "p.stdin.close()" line is uncommented.  It seems that stdin only flushes to the process on stdin.close(), not on stdin.flush().


import subprocess as subp
import threading
import time

p = subp.Popen(["tr", "[:lower:]", "[:upper:]"],
    stdin=subp.PIPE, stderr=subp.PIPE, stdout=subp.PIPE, close_fds=True)

def read(stdout):
    while True:
        line = stdout.readline()
        if not line: break

t = threading.Thread(target=read, args=(p.stdout,))
t.daemon = True



components: None
messages: 153257
nosy: amoffat
priority: normal
severity: normal
status: open
title: Subprocess stdin.flush does not flush
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list