possible bug?

Jeff Epler jepler at unpythonic.net
Tue Mar 22 14:43:22 EST 2005


I wrote a program to use subprocess.Popen 10000 times, and never had
.wait() hang.  If this is a bug, it may be Windows specific.

Here's the program I ran:
#-------------------------------------------------------------------------
import subprocess, signal
def timeout(*args):
    print "Timed out waiting on", i
    raise SystemExit, 1

signal.signal(signal.SIGALRM, timeout)

for i in xrange(10000):
    signal.alarm(5)
    subprocess.Popen(['/bin/true']).wait()
    if i % 100 == 0: print "done with", i
print "done!"
#-------------------------------------------------------------------------

If the wait method ever hangs, the signal handler shuld be invoked.  On
Unix, "/bin/true" is a very simple program that does nothing, so it's
virtually guaranteed to run in less than 5 seconds.  On Windows, maybe
you want something like subprocess.popen('cmd.exe /c rem') as a command
that will do nothing and terminate quickly.  What happens if you run my
program with that change to the Popen line?

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050322/282bc8cc/attachment.sig>


More information about the Python-list mailing list