MCPcopy Create free account
hub / github.com/FastMAS/KVCOMM / function_with_timeout

Function function_with_timeout

KVCOMM/tools/coding/executor_utils.py:34–47  ·  view source on GitHub ↗
(func, args, timeout)

Source from the content-addressed store, hash-verified

32
33
34def function_with_timeout(func, args, timeout):
35 result_container = []
36
37 def wrapper():
38 result_container.append(func(*args))
39
40 thread = PropagatingThread(target=wrapper)
41 thread.start()
42 thread.join(timeout)
43
44 if thread.is_alive():
45 raise TimeoutError()
46 else:
47 return result_container[0]
48
49

Callers 3

get_outputFunction · 0.90
executeMethod · 0.90
evaluateMethod · 0.90

Calls 2

joinMethod · 0.95
PropagatingThreadClass · 0.85

Tested by

no test coverage detected