[New-bugs-announce] [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
print(line.decode("utf8"))
t = threading.Thread(target=read, args=(p.stdout,))
t.daemon = True
t.start()
p.stdin.write("uppercase\n".encode())
p.stdin.flush()
#p.stdin.close()
time.sleep(1)
----------
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>
<http://bugs.python.org/issue14000>
_______________________________________
More information about the New-bugs-announce
mailing list