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
pgpxqq83N7cWo.pgp
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list
