lightly modified version of my patch

[ 971323 ] make test_signal less annoying
after some comments on IRC from a highly opinionated australian who
wishes to remain anonymous.
This commit is contained in:
Michael W. Hudson 2004-06-11 18:09:28 +00:00
parent c982bbde1c
commit 5c26e86096
1 changed files with 33 additions and 26 deletions

View File

@ -17,11 +17,11 @@ script = """
(
set %(x)s
sleep 2
kill -5 %(pid)d
kill -HUP %(pid)d
sleep 2
kill -2 %(pid)d
kill -USR1 %(pid)d
sleep 2
kill -3 %(pid)d
kill -USR2 %(pid)d
) &
""" % vars()
@ -37,29 +37,36 @@ def handlerB(*args):
raise HandlerBCalled, args
signal.alarm(20) # Entire test lasts at most 20 sec.
signal.signal(5, handlerA)
signal.signal(2, handlerB)
signal.signal(3, signal.SIG_IGN)
signal.signal(signal.SIGALRM, signal.default_int_handler)
os.system(script)
print "starting pause() loop..."
hup = signal.signal(signal.SIGHUP, handlerA)
usr1 = signal.signal(signal.SIGUSR1, handlerB)
usr2 = signal.signal(signal.SIGUSR2, signal.SIG_IGN)
alrm = signal.signal(signal.SIGALRM, signal.default_int_handler)
try:
while 1:
if verbose:
print "call pause()..."
try:
signal.pause()
if verbose:
print "pause() returned"
except HandlerBCalled:
if verbose:
print "HandlerBCalled exception caught"
else:
pass
os.system(script)
except KeyboardInterrupt:
if verbose:
print "KeyboardInterrupt (assume the alarm() went off)"
print "starting pause() loop..."
try:
while 1:
if verbose:
print "call pause()..."
try:
signal.pause()
if verbose:
print "pause() returned"
except HandlerBCalled:
if verbose:
print "HandlerBCalled exception caught"
else:
pass
except KeyboardInterrupt:
if verbose:
print "KeyboardInterrupt (assume the alarm() went off)"
finally:
signal.signal(signal.SIGHUP, hup)
signal.signal(signal.SIGUSR1, usr1)
signal.signal(signal.SIGUSR2, usr2)
signal.signal(signal.SIGALRM, alrm)