[Python-Dev] subprocess crossplatformness and async communication

Daniel Stutzbach daniel at stutzbachenterprises.com
Mon Jan 26 16:19:01 CET 2009


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 <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090126/e0466e2f/attachment.htm>


More information about the Python-Dev mailing list