code: def signal_handler_as(sig, handler):
    
    old_handler = signal.signal(sig, handler)
    try:
      yield
    finally:
      signal.signal(sig, old_handler)
docs: Temporarily replaces a signal handler for the given signal and restores the old handler.
  
    :param int sig: The target signal to replace the handler for (e.g. signal.SIGINT).
    :param func handler: The new temporary handler.