summaryrefslogtreecommitdiff
path: root/thread_utils.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2022-06-02 08:23:18 -0700
committerScott Gasch <[email protected]>2022-06-02 08:23:18 -0700
commita0722abe80c416e0c174f3ff861566834402d43b (patch)
treeb80aaff7a143fc7eae3165d4174789a794d72f30 /thread_utils.py
parent2a6d7810f85b88fb89d11d3e6be64f974ab77f97 (diff)
Initial stab at a smarter doc/unit/integration/coverage test runner.
Diffstat (limited to 'thread_utils.py')
-rw-r--r--thread_utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/thread_utils.py b/thread_utils.py
index 65f6037..df637e0 100644
--- a/thread_utils.py
+++ b/thread_utils.py
@@ -120,6 +120,27 @@ def background_thread(
return wrapper(_funct)
+class ThreadWithReturnValue(threading.Thread):
+ """A thread whose return value is plumbed back out as the return
+ value of :meth:`join`.
+ """
+
+ def __init__(self, group=None, target=None, name=None, args=(), kwargs={}, Verbose=None):
+ threading.Thread.__init__(
+ self, group=None, target=target, name=None, args=args, kwargs=kwargs
+ )
+ self._target = target
+ self._return = None
+
+ def run(self):
+ if self._target is not None:
+ self._return = self._target(*self._args, **self._kwargs)
+
+ def join(self, *args):
+ threading.Thread.join(self, *args)
+ return self._return
+
+
def periodically_invoke(
period_sec: float,
stop_after: Optional[int],