summaryrefslogtreecommitdiff
path: root/decorator_utils.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2021-04-23 17:13:11 -0700
committerScott Gasch <[email protected]>2021-04-23 17:13:11 -0700
commite0973abee4c917127169795a56fd9c5c5412913c (patch)
treeb495199b55ca09848325db342da29819eddcdd25 /decorator_utils.py
parentbf508f86e1576736d18cab08edbca834456045ee (diff)
Move TimeoutError to central exceptions file.
Diffstat (limited to 'decorator_utils.py')
-rw-r--r--decorator_utils.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/decorator_utils.py b/decorator_utils.py
index 4d882be..03e7c88 100644
--- a/decorator_utils.py
+++ b/decorator_utils.py
@@ -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.