flaw in class popen2.Popen3

HP hp at rentec.com
Mon Oct 21 00:07:52 EDT 2002


I have the following code which has trouble in certain condition:

-------------------------------------------------------
import time, popen2;   # python 2.1 and 2.2

machine = # a machine name
cmd = # a unix command  (Sun Sparc with Solaris, or PC with linux)

p = popen2.Popen3("rsh %s '%s'" % (machine, cmd));

while (p.poll()):
    time.sleep(1);
-------------------------------------------------------

If cmd only produces one line of output (such as 'date'), 
then the above while loop will exit very quickly.
HOWEVER, if cmd produces a large piece of data (such as 'cat LARGE_FILE')
then the while loop will hang there forever.

Any exiting fix for this problem ???
HP



More information about the Python-list mailing list