def exit_by_exception():
class SignalException(BaseException):
pass
def signal_fork(signum, stack_frame):
log.info('Received signal %d, procuring hariki', signum)
raise SignalException(signum)
def excepthook(exc_type, exc_value, exc_trace):
if exc_type is SignalException:
sys.exit(1)
else:
sys.__excepthook__(exc_type, exc_value, exc_trace)
sys.excepthook = excepthook
signal.signal(signal.SIGINT, signal_fork)
signal.signal(signal.SIGTERM, signal_fork)
评论列表
文章目录