예제 #1
0
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())
예제 #2
0
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())
예제 #3
0
def upgradeHandler(signum):
    signal.signal(signum, improvedSignalHandler)
    signame = get_signal_name(signum)
    LOG.debug("Upgraded sighandler for %s", signame)