subprocess -popen - reading stdout from child - hangs

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Sun Sep 23 22:57:58 EDT 2007


In message <1190521003.928634.48900 at d55g2000hsg.googlegroups.com>,
gregpinero at gmail.com wrote:

> Well, using this subclass of subprocess.Popen fixes the problem
> (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554)
> 
> I don't understand how it works though.  Would anyone mind
> explaining?  I'm thinking there's something fundamental about Unix
> processes I'm not understanding.

The "select" calls are checking that the subprocess is ready to read before
writing to its stdin, or that it has something to write before reading from
its stdout.

The O_NONBLOCK fcntl simply says not to wait if there is nothing more to be
read, just return what was already read.



More information about the Python-list mailing list