code: def add_signal_handler():
      
      import signal
  
      def handler(sig, frame):
          if sig == signal.SIGINT:
              librtmp.RTMP_UserInterrupt()
              raise KeyboardInterrupt
  
      signal.signal(signal.SIGINT, handler)
docs: Adds a signal handler to handle KeyboardInterrupt.