Message153257
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) |
|
Date |
User |
Action |
Args |
2012-02-13 09:54:09 | amoffat | set | recipients:
+ amoffat |
2012-02-13 09:54:09 | amoffat | set | messageid: <1329126849.72.0.845817080547.issue14000@psf.upfronthosting.co.za> |
2012-02-13 09:54:09 | amoffat | link | issue14000 messages |
2012-02-13 09:54:08 | amoffat | create | |
|