def handler(self, signum, frame): # pragma: no cover '''Signal handler for this process''' if signum in (signal.SIGTERM, signal.SIGINT, signal.SIGQUIT, signal.SIGHUP): for cpid in self.sandboxes.keys(): os.kill(cpid, signum) if signum == signal.SIGHUP: # HUP - reload logging configuration _reloadLogger() else: exit(0)
def handler(self, signum, frame): # pragma: no cover '''Signal handler for this process''' if signum == signal.SIGQUIT: # QUIT - Finish processing, but don't do any more work after that self.stop() elif signum == signal.SIGUSR1: # USR1 - Print the backtrace message = ''.join(traceback.format_stack(frame)) message = 'Signaled traceback for %s:\n%s' % (os.getpid(), message) print message logger.warn(message) elif signum == signal.SIGUSR2: # USR2 - Enter a debugger # Much thanks to http://stackoverflow.com/questions/132058 data = {'_frame': frame} # Allow access to frame object. data.update(frame.f_globals) # Unless shadowed by global data.update(frame.f_locals) # Build up a message with a traceback message = ''.join(traceback.format_stack(frame)) message = 'Traceback:\n%s' % message code.InteractiveConsole(data).interact(message) elif signum ==signal.SIGHUP: # HUP - reload logging configuration _reloadLogger()