Writing to open subprocess pipes.

Stephen Hansen me+list/python at ixokai.io
Wed Jun 16 17:30:46 EDT 2010


On 6/16/10 1:29 PM, Brandon McGinty wrote:
> Both subprocess and os.popen* only allow inputput and output one time,
> and the output to be read only when the process terminates.

Its not that subprocess only *allow* input and output one at a time, but
that it a) provides blocking file objects by default, and b) those only
read until EOF.

It also provides *convenience* methods for the common case of writing
output once and receiving everything back, but that's not the only way
you can use it.

If you want a bidirectional write/read for awhile, you really just need
to switch those file objects to non-blocking and such.

I found this useful when I needed to do it:
http://code.activestate.com/recipes/440554/

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20100616/111c1e96/attachment-0001.sig>


More information about the Python-list mailing list