popen4 doesn't block?

Terry Hancock hancock at anansispaceworks.com
Wed Jan 29 09:15:19 EST 2003


Dennis Lee Bieber wrote:
>         Strike that... based upon other posters it does look like you need
>         to
> do all the writes first, /then/ do a read which blocks until the
> process ends.

Yeah, that's the right answer, it worked very well (thought I should cap 
this, since I left it a little vague before -- the remaining bug was a 
trivial typo).  Thanks a lot for the suggestions!

Of course I realized as soon as I tried it that popen can't block for 
obvious logical reasons, but I hadn't thought it through to a solution.
In fact, I've used popen before, but I always closed it right away, so I 
never really thought about how it worked.  That .read() blocks is very 
sensible (I suppose .readline() would not, though).  Of course, once I read 
the data, I'm free to close it right away, too, so things work out very 
smoothly.

Cheers,
Terry

-- 
Anansi Spaceworks
http://www.anansispaceworks.com




More information about the Python-list mailing list