@contextmanager
def in_sighandler():
 set_in_sighandler(True)
 try:
  (yield)
 finally:
  set_in_sighandler(False)

@ contextmanager def in_sighandler ( ) : set_in_sighandler ( True ) try : ( yield ) finally : set_in_sighandler ( False )
context that records that we are in a signal handler .