original_docstring: 
      Appends signal handler instead of replacing any existing. Remember this is only possible from main thread.
      
docstring: Appends signal handler instead of replacing any existing. Remember this is only possible from main thread.
docstring_tokens: Appends signal handler instead of replacing any existing . Remember this is only possible from main thread .
code: def append_signal_handler_for(sig, func):
      """
      Appends signal handler instead of replacing any existing. Remember this is only possible from main thread.
      """
  
      # Check for existing handler
      old = None
      if callable(signal.getsignal(sig)):
          old = signal.getsignal(sig)
  
      def wrapper(*args, **kwargs):
  
          # Call old first
          if old != None:
              try:
                  old(*args, **kwargs)
              except SystemExit:
                  pass
              except:
                  log.exception("Error in signal handler {:} for signal number {:}".format(old, sig))
  
          # Then call new
          func(*args, **kwargs)
  
      # Register wrapper
      signal.signal(sig, wrapper)
code_tokens: def append_signal_handler_for ( sig , func ) : old = None if callable ( signal . getsignal ( sig ) ) : old = signal . getsignal ( sig ) def wrapper ( * args , ** kwargs ) : if old != None : try : old ( * args , ** kwargs ) except SystemExit : pass except : log . exception ( "Error in signal handler {:} for signal number {:}" . format ( old , sig ) ) func ( * args , ** kwargs ) signal . signal ( sig , wrapper )
short_docstring: Appends signal handler instead of replacing any existing.
short_docstring_tokens: Appends signal handler instead of replacing any existing .
comment: """
      Appends signal handler instead of replacing any existing. Remember this is only possible from main thread.
      """$SEP$# Check for existing handler$SEP$# Call old first$SEP$# Then call new$SEP$# Register wrapper