Move TimeoutError to central exceptions file.
authorScott Gasch <[email protected]>
Sat, 24 Apr 2021 00:13:11 +0000 (17:13 -0700)
committerScott Gasch <[email protected]>
Sat, 24 Apr 2021 00:13:11 +0000 (17:13 -0700)
decorator_utils.py
exceptions.py

index 4d882bed7ac4486db741b76b587b402a6dac147e..03e7c880433fad5d359a2bb3acc29a4266204e65 100644 (file)
@@ -17,6 +17,7 @@ import traceback
 from typing import Callable, Optional
 import warnings
 
+import exceptions
 import thread_utils
 
 logger = logging.getLogger(__name__)
@@ -317,14 +318,6 @@ def thunkify(func):
 # in https://code.google.com/p/verse-quiz/source/browse/trunk/timeout.py
 
 
-class TimeoutError(AssertionError):
-    def __init__(self, value: str = "Timed Out"):
-        self.value = value
-
-    def __str__(self):
-        return repr(self.value)
-
-
 def _raise_exception(exception, error_message: Optional[str]):
     if error_message is None:
         raise exception()
@@ -417,7 +410,7 @@ class _Timeout(object):
 def timeout(
     seconds: float = 1.0,
     use_signals: Optional[bool] = None,
-    timeout_exception=TimeoutError,
+    timeout_exception=exceptions.TimeoutError,
     error_message="Function call timed out",
 ):
     """Add a timeout parameter to a function and return the function.
index 3ce94d365774422252ab591303907d31ff65d1ba..3e0a2d080b56742d71d1d02ee45ac13fd8d5a146 100644 (file)
@@ -9,5 +9,8 @@ class PostconditionException(AssertionError):
 
 
 class TimeoutError(Exception):
-    pass
+    def __init__(self, value: str = "Timed out"):
+        self.value = value
 
+    def __str__(self):
+        return repr(self.value)