I'm running ActivePython PythonWin 2.4, and get the error message"'AributeError: 'module' object has no attribute 'SIGALRM'". The example provided in the ActivePython documents use signal.SIGALRM, so I'm not sure what's going on...
Earl On Tue, 2005-03-22 at 12:43, Jeff Epler wrote: > 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 -- http://mail.python.org/mailman/listinfo/python-list