MCPcopy Index your code
hub / github.com/omkarcloud/botasaurus / ThreadWithResult

Class ThreadWithResult

botasaurus/thread_with_result.py:3–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1from threading import Thread
2
3class ThreadWithResult(Thread):
4 def __init__(
5 self, group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None
6 ):
7 self.result = None
8 self._exception = None
9
10 def function():
11 try:
12 self.result = target(*args, **kwargs)
13 except Exception as e:
14 self._exception = e
15
16 super().__init__(group=group, target=function, name=name, daemon=daemon)
17
18 def join(self, timeout=None):
19 super().join(timeout)
20 if self._exception:
21 raise self._exception

Callers 1

run_parallelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected