<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def signal_handler_as(sig, handler):
 """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. """

  old_handler = signal.signal(sig, handler)
  try:
    yield
  finally:
    signal.signal(sig, old_handler)