Admittedly I haven't had time to dig into the library source, but this
behavior certainly doesn't seem right. Here's a test case:
"""Test program to demonstrate problem with popen2 module."""
import popen2
def main (argv):
mycmd = 'python2.3 -c "for i in range(100000):\n print i"'
p = popen2.Popen3(mycmd)
print 'result code is %d' % p.wait()
for line in p.fromchild.xreadlines():
print line,
if __name__ == '__main__':
import sys
main(sys.argv)
As you can see I'm using the popen2.Popen3 class to run a process
which prints a lot of output.
Here's the problem: for small values of the constant in the range()
call, e.g. 1000, this works as expected. For larger values, e.g.
100,000, the program never returns from the p.wait() call after the
child process completes. It appears tbe waiting forever on the
waitpid() call.
This is occuring on a Sun server:
uname -a SunOS fred 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Fire-880
and I've seen the exact same behavior under HP-UX: uname -a
HP-UX hpserver B.11.11 U 9000/800 2243344530 unlimited-user license
I don't see this behavior with calling os.popen(). I DO see it with
the current implementation of popen5() from the PEP.
Does anyone know why this is occurring? Is this a bona-fide bug? Or
am I just being stupid somehow?
Thanks!
A. Lloyd Flanagan
Contract Programmer
Richmond, VA