[Python-Dev] subprocess crossplatformness and async communication (original) (raw)
Daniel Stutzbach daniel at stutzbachenterprises.com
Mon Jan 26 16:19:01 CET 2009
- Previous message: [Python-Dev] subprocess crossplatformness and async communication
- Next message: [Python-Dev] subprocess crossplatformness and async communication
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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>
- Previous message: [Python-Dev] subprocess crossplatformness and async communication
- Next message: [Python-Dev] subprocess crossplatformness and async communication
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]