def improvedSignalHandler(signum, frame): """Improved signal handler that dispatches to registered handlers.""" signame = get_signal_name(signum) LOG.info("Caught signal %s" % signame) for handler in OriginalSignalHandler.registry.get(signum, []): # Never let a bad handler prevent the standard signal # handlers from running. try: if inspect.getargspec(handler).args: handler(signum, frame) else: handler() except Exception: LOG.warn('A handler for %s failed!' % signame, exc_info=sys.exc_info())
def improvedSignalHandler(signum, frame): """Improved signal handler that dispatches to registered handlers.""" signame = get_signal_name(signum) LOG.info("Caught signal %s" % signame) for handler in OriginalSignalHandler.registry.get(signum, []): # Never let a bad handler prevent the standard signal # handlers from running. try: if inspect.getargspec(handler).args: handler(signum, frame) else: handler() except SystemExit: # if we trap SystemExit, we can't restart raise except: LOG.warn('A handler for %s failed!' % signame, exc_info=sys.exc_info())
def upgradeHandler(signum): signal.signal(signum, improvedSignalHandler) signame = get_signal_name(signum) LOG.debug("Upgraded sighandler for %s", signame)