diff options
author | Michael W. Hudson <mwh@python.net> | 2004-06-11 18:09:28 (GMT) |
---|---|---|
committer | Michael W. Hudson <mwh@python.net> | 2004-06-11 18:09:28 (GMT) |
commit | 5c26e860960ca30341ed61c8f20c34b0667ad315 (patch) | |
tree | d7c4b0dcf4724c02fad896ce76ac2fe7456556c5 /Lib/test/test_signal.py | |
parent | c982bbde1c5012202187b8e398fd631b6cec214b (diff) | |
download | cpython-5c26e860960ca30341ed61c8f20c34b0667ad315.zip cpython-5c26e860960ca30341ed61c8f20c34b0667ad315.tar.gz cpython-5c26e860960ca30341ed61c8f20c34b0667ad315.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_signal.py')
-rw-r--r-- | Lib/test/test_signal.py | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index 75365fd..5c11322 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -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) +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) -os.system(script) +try: + os.system(script) -print "starting pause() loop..." + print "starting pause() loop..." -try: - while 1: - if verbose: - print "call pause()..." - try: - signal.pause() - if verbose: - print "pause() returned" - except HandlerBCalled: + try: + while 1: if verbose: - print "HandlerBCalled exception caught" - else: - pass + 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)" + 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) |