code: def suppress_interrupt():
      
      interrupted = False
  
      def sigint_handler(signum, frame):
          nonlocal interrupted
          interrupted = True
      
      s = signal.signal(signal.SIGINT, sigint_handler)
      try:
          yield None
      finally:
          signal.signal(signal.SIGINT, s)
      if interrupted:
          raise KeyboardInterrupt()
docs: Suppress KeyboardInterrupt exceptions while the context is active.
      
      The suppressed interrupt (if any) is raised when the context is exited.