diff options
Diffstat (limited to 'systrace/catapult/devil/devil/utils/reraiser_thread.py')
-rw-r--r-- | systrace/catapult/devil/devil/utils/reraiser_thread.py | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/systrace/catapult/devil/devil/utils/reraiser_thread.py b/systrace/catapult/devil/devil/utils/reraiser_thread.py index 6e6c810..56d95f3 100644 --- a/systrace/catapult/devil/devil/utils/reraiser_thread.py +++ b/systrace/catapult/devil/devil/utils/reraiser_thread.py @@ -11,14 +11,12 @@ import threading import time import traceback -from devil import base_error from devil.utils import watchdog_timer -class TimeoutError(base_error.BaseError): +class TimeoutError(Exception): """Module-specific timeout exception.""" - def __init__(self, message): - super(TimeoutError, self).__init__(message) + pass def LogThreadStack(thread, error_log_func=logging.critical): @@ -49,13 +47,10 @@ class ReraiserThread(threading.Thread): func: callable to call on a new thread. args: list of positional arguments for callable, defaults to empty. kwargs: dictionary of keyword arguments for callable, defaults to empty. - name: thread name, defaults to the function name. + name: thread name, defaults to Thread-N. """ - if not name: - if hasattr(func, '__name__') and func.__name__ != '<lambda>': - name = func.__name__ - else: - name = 'anonymous' + if not name and func.__name__ != '<lambda>': + name = func.__name__ super(ReraiserThread, self).__init__(name=name) if not args: args = [] @@ -69,17 +64,10 @@ class ReraiserThread(threading.Thread): self._exc_info = None self._thread_group = None - if sys.version_info < (3,): - # pylint: disable=exec-used - exec('''def ReraiseIfException(self): - """Reraise exception if an exception was raised in the thread.""" - if self._exc_info: - raise self._exc_info[0], self._exc_info[1], self._exc_info[2]''') - else: - def ReraiseIfException(self): - """Reraise exception if an exception was raised in the thread.""" - if self._exc_info: - raise self._exc_info[1] + def ReraiseIfException(self): + """Reraise exception if an exception was raised in the thread.""" + if self._exc_info: + raise self._exc_info[0], self._exc_info[1], self._exc_info[2] def GetReturnValue(self): """Reraise exception if present, otherwise get the return value.""" |