projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Better logging + cleanup.
[python_utils.git]
/
decorator_utils.py
diff --git
a/decorator_utils.py
b/decorator_utils.py
index 5d1e779deeeaa3df34547f853ce5e4fc0cdcb87b..80aec4aaae788023f04588d4a78327a761cf1638 100644
(file)
--- a/
decorator_utils.py
+++ b/
decorator_utils.py
@@
-1,5
+1,8
@@
#!/usr/bin/env python3
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+# Portions (marked) below retain the original author's copyright.
+
"""Decorators."""
import enum
"""Decorators."""
import enum
@@
-15,7
+18,7
@@
import threading
import time
import traceback
import warnings
import time
import traceback
import warnings
-from typing import Any, Callable, Optional
+from typing import Any, Callable,
List,
Optional
# This module is commonly used by others in here and should avoid
# taking any unnecessary dependencies back on them.
# This module is commonly used by others in here and should avoid
# taking any unnecessary dependencies back on them.
@@
-507,7
+510,7
@@
def thunkify(func):
wait_event = threading.Event()
result = [None]
wait_event = threading.Event()
result = [None]
- exc = [False, None]
+ exc
: List[Any]
= [False, None]
def worker_func():
try:
def worker_func():
try:
@@
-524,6
+527,7
@@
def thunkify(func):
def thunk():
wait_event.wait()
if exc[0]:
def thunk():
wait_event.wait()
if exc[0]:
+ assert exc[1]
raise exc[1][0](exc[1][1])
return result[0]
raise exc[1][0](exc[1][1])
return result[0]
@@
-670,7
+674,7
@@
def timeout(
def decorate(function):
if use_signals:
def decorate(function):
if use_signals:
- def handler(
signum,
frame):
+ def handler(
unused_signum, unused_
frame):
_raise_exception(timeout_exception, error_message)
@functools.wraps(function)
_raise_exception(timeout_exception, error_message)
@functools.wraps(function)