listen/signal_handler.py
def default_handler(self, signum, frame):
        """ Default handler, a generic callback method for signal processing"""
        self.log.debug("Signal handler called with signal: {0}".format(signum))
        # 1. If signal is HUP restart the python process
        # 2. If signal is TERM, INT or QUIT we try to cleanup then exit with -1
        # 3. If signal is STOP or TSTP we pause
        # 4. If signal is CONT or USR1 we continue
        # 5. If signal is INFO we print status
        # 6. If signal is USR2 we we abort and then exit with -1

        if signum in self.restart_signals:
            self.set_handler(self.handled_signals, self.pseudo_handler)
            self._cleanup()
            os.execl('python', 'python', * sys.argv)
        elif signum in self.abort_signals:
            self.abort(signum)
        elif signum in self.pause_signals:
            self.pause(signum)
        elif signum in self.resume_signals:
            self.resume(signum)
        elif signum in self.status_signals:
            self.status(signum)
        elif signum in self.error_signals:
            self.log.error('Signal handler received error signal from an external process, aborting')
            self.abort(signum)
        else:
            self.log.error("Unhandled signal received: {0}".format(signum))
            raise
def default_handler(self, signum, frame):
        """ Default handler, a generic callback method for signal processing"""
        self.log.debug("Signal handler called with signal: {0}".format(signum))
        # 1. If signal is HUP restart the python process
        # 2. If signal is TERM, INT or QUIT we try to cleanup then exit with -1
        # 3. If signal is STOP or TSTP we pause
        # 4. If signal is CONT or USR1 we continue
        # 5. If signal is INFO we print status
        # 6. If signal is USR2 we we abort and then exit with -1

        if signum in self.restart_signals:
            self.set_handler(self.handled_signals, self.pseudo_handler)
            self._cleanup()
            os.execl('python', 'python', * sys.argv)
        elif signum in self.abort_signals:
            self.abort(signum)
        elif signum in self.pause_signals:
            self.pause(signum)
        elif signum in self.resume_signals:
            self.resume(signum)
        elif signum in self.status_signals:
            self.status(signum)
        elif signum in self.error_signals:
            self.log.error('Signal handler received error signal from an external process, aborting')
            self.abort(signum)
        else:
            self.log.error("Unhandled signal received: {0}".format(signum))
            raise
Default handler, a generic callback method for signal processing