[Python-bugs-list] popen2.Popen3.wait() hangs (PR#421)

bwhite@cch.com.au bwhite@cch.com.au
Mon, 31 Jul 2000 03:11:18 -0400 (EDT)


Full_Name: Brian White
Version: 1.5.2
OS: SunOS 5.5.1
Submission from: hades.cch.com.au (203.18.39.1)


I think this is probably the same bug as #385 - I do have a little more detail
however. I was looking for a way to "attach" extra info to #385 and failed.

For me, the wait action was hanging when the process I was running was
generating too much standard output.

To test it, I wrote one utility called "dots" to generate N dots:

 #!/usr/local/bin/python
 
 import sys
 
 if len( sys.argv) <= 1:
    print "Prints out the specified number of dots"
 else:
    numdots = int( sys.argv[1] )
    sys.stdout.write( "." * numdots )


And another called popen3test :

 #!/usr/local/bin/python
 
 import sys, popen2
 
 if len( sys.argv) <= 1:
    print "Test for popen3 - specified stdout size"
 else:
    charsize = int( sys.argv[1] )
    bufsize  = -1
  
    if len( sys.argv ) > 2:
       bufsize = int( sys.argv[2] )
 
    popper = popen2.Popen3( "dots " + str(charsize) , bufsize = bufsize )
    popper.wait() # It HANGS HERE
 
    sys.stdout.writelines( popper.fromchild.readlines() )


I then ran this as "popen3test <N> <BS>" where
  N   is the number of bytes of stdout it generates
  BS  is the bufsize
with various values of N and BS

From this I was able to determine that 
   1) For N <= 10240  it works fine
      For N >  10240  it hangs
   2) The value of BS is immaterial 

The traceback on ^C was

 Traceback (innermost last):
   File "popen3test", line 15, in ?
     popper.wait()
   File "/usr/local/lib/python1.5/popen2.py", line 65, in wait
     pid, sts = os.waitpid(self.pid, 0)
 KeyboardInterrupt