mirror of
https://github.com/python/cpython.git
synced 2026-02-05 09:25:35 +00:00
Verify that the signal handlers were really called
This commit is contained in:
parent
c173b488dc
commit
ec3c5e396e
1 changed files with 12 additions and 0 deletions
|
|
@ -25,7 +25,11 @@
|
|||
) &
|
||||
""" % vars()
|
||||
|
||||
a_called = b_called = False
|
||||
|
||||
def handlerA(*args):
|
||||
global a_called
|
||||
a_called = True
|
||||
if verbose:
|
||||
print "handlerA", args
|
||||
|
||||
|
|
@ -33,6 +37,8 @@ class HandlerBCalled(Exception):
|
|||
pass
|
||||
|
||||
def handlerB(*args):
|
||||
global b_called
|
||||
b_called = True
|
||||
if verbose:
|
||||
print "handlerB", args
|
||||
raise HandlerBCalled, args
|
||||
|
|
@ -88,6 +94,12 @@ def handlerB(*args):
|
|||
if verbose:
|
||||
print "KeyboardInterrupt (assume the alarm() went off)"
|
||||
|
||||
if not a_called:
|
||||
print 'HandlerA not called'
|
||||
|
||||
if not b_called:
|
||||
print 'HandlerB not called'
|
||||
|
||||
finally:
|
||||
signal.signal(signal.SIGHUP, hup)
|
||||
signal.signal(signal.SIGUSR1, usr1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue