(original) (raw)
I'm confused. What's wrong with the following?
p = Popen('do_something', stdin=PIPE, stdout=PIPE)
p.stdin.write('la la la\n')
p.stdin.flush()
line = p.stdout.readline()
p.stdin.write(process(line))
p.stdin.flush()
If you want to see if data is available on p.stdout, use the select module (unless you're on Windows).
The child process has to flush its output buffer for this to work, but that isn't Python's problem.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC