programme call with popen

Donn Cave donn at u.washington.edu
Wed Aug 29 15:27:45 EDT 2001


Quoth Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl>:
| Wed, 29 Aug 2001 10:24:03 -0700, Jeff Shannon <jeff at ccvcorp.com> pisze:
|
| >>>> myoutput = fout.read()
| > 
| > Note that this will block until the program has finished running.
|
| I'm not sure about Windows, but it won't block that long on Unix.
| Both processes will run in parallel exchanging data. The consumer
| will temporarily block when the queue is empty and the producer will
| block when the queue's buffer is full.

That would be true if both parties used system level I/O functions
posix.read and posix.write - which is in my opinion a really good
idea in a situation like this.

But the file object shown above will have its own process buffering,
from the C library.  He's right about what happens in that example,
give it a try with fin, fout = os.popen2('ping xxx.yyy.zzz') or
something like that.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list