Move SignalExit to errors.py

This commit is contained in:
Blake Griffith
2016-07-05 23:14:53 -05:00
parent 92870f0bbb
commit 777a654d90
2 changed files with 7 additions and 10 deletions
+3 -10
View File
@@ -5,6 +5,7 @@ import os
import signal
import traceback
from certbot import errors
logger = logging.getLogger(__name__)
@@ -19,14 +20,6 @@ _SIGNALS = ([signal.SIGTERM] if os.name == "nt" else
signal.SIGXCPU, signal.SIGXFSZ])
class SignalExit(Exception):
"""This exception is used stop of execution of the code in the body of the
ErrorHandler context manager.
"""
pass
class ErrorHandler(object):
"""Registers functions to be called if an exception or signal occurs.
@@ -62,7 +55,7 @@ class ErrorHandler(object):
def __exit__(self, exec_type, exec_value, trace):
self.body_executed = True
retval = False
if exec_type is SignalExit:
if exec_type is errors.SignalExit:
logger.debug("Encountered signals: %s", self.received_signals)
self.call_registered()
for signum in self.received_signals:
@@ -120,7 +113,7 @@ class ErrorHandler(object):
"""
self.received_signals.append(signum)
if not self.body_executed:
raise SignalExit
raise errors.SignalExit
def call_signal(self, signum):
"""Calls the signal given by signum.
+4
View File
@@ -29,6 +29,10 @@ class HookCommandNotFound(Error):
"""Failed to find a hook command in the PATH."""
class SignalExit(Error):
"""A Unix signal was recieved while in the ErrorHandler context manager."""
# Auth Handler Errors
class AuthorizationError(Error):
"""Authorization error."""