MCPcopy Create free account
hub / github.com/Tong89/smartNode / _concurrent_submit

Function _concurrent_submit

tests/test_concurrency.py:63–80  ·  view source on GitHub ↗

启动 n_threads 个线程,每线程提交 per_thread 次,返回 (results, errors)。

(engine, n_threads, per_thread)

Source from the content-addressed store, hash-verified

61
62
63def _concurrent_submit(engine, n_threads, per_thread):
64 """启动 n_threads 个线程,每线程提交 per_thread 次,返回 (results, errors)。"""
65 results = []
66 errors = []
67 # 使用屏障让所有线程尽可能同步启动
68 barrier = threading.Barrier(n_threads)
69 threads = [
70 threading.Thread(
71 target=_submit_n,
72 args=(engine, per_thread, results, errors, barrier),
73 )
74 for _ in range(n_threads)
75 ]
76 for t in threads:
77 t.start()
78 for t in threads:
79 t.join(timeout=30)
80 return results, errors
81
82
83# ---------------------------------------------------------------------------

Calls

no outgoing calls

Tested by

no test coverage detected