MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / run_with_timeout

Function run_with_timeout

tests/model_loader/utils.py:58–78  ·  view source on GitHub ↗
(target, args=(), kwargs={}, timeout=60 * 5)

Source from the content-addressed store, hash-verified

56
57
58def run_with_timeout(target, args=(), kwargs={}, timeout=60 * 5):
59 clear_logs()
60 result_queue = Queue()
61 wrapped_target = partial(target, result_queue=result_queue)
62 p = Process(target=wrapped_target, args=args, kwargs=kwargs)
63 p.start()
64 p.join(timeout)
65 if p.is_alive():
66 p.terminate()
67 print_logs()
68 raise RuntimeError("Worker process hung and was terminated")
69 try:
70 result = result_queue.get(timeout=60)
71 except Exception as e:
72 raise RuntimeError(f"Failed to get result from worker: {e}")
73 finally:
74 result_queue.close()
75 result_queue.join_thread()
76 clean_ports([FD_CACHE_QUEUE_PORT])
77
78 return result
79
80
81def form_model_get_output_topp0(

Callers 4

test_model_cacheFunction · 0.90
test_offline_modelFunction · 0.90

Calls 9

getMethod · 0.95
clear_logsFunction · 0.85
QueueClass · 0.85
print_logsFunction · 0.85
joinMethod · 0.80
terminateMethod · 0.80
clean_portsFunction · 0.70
startMethod · 0.45
closeMethod · 0.45

Tested by 4

test_model_cacheFunction · 0.72
test_offline_modelFunction · 0.72