New submission from Andrew Moffat <[email protected]>:
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 <[email protected]>
<http://bugs.python.org/issue14000>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com