Skip to content

Parallelize adapter execution in run_all via ThreadPoolExecutor - #68

Open
qiaobochi040726-source wants to merge 2 commits into
BreachDirect:mainfrom
qiaobochi040726-source:20260806-parallel-adapters
Open

Parallelize adapter execution in run_all via ThreadPoolExecutor#68
qiaobochi040726-source wants to merge 2 commits into
BreachDirect:mainfrom
qiaobochi040726-source:20260806-parallel-adapters

Conversation

@qiaobochi040726-source

Copy link
Copy Markdown
Contributor

Fixes #45

适配器并发执行(ThreadPoolExecutor,线程池——适配器是 IO/子进程重、CPU 轻):

  • _run_one() 提取单适配器执行,AdapterError/意外异常 → 错误条目,不拖垮其他适配器
  • max_workers = 启用适配器数;submit 与 f.result() 都按配置顺序 → 报告顺序不变
  • 空启用集返回 []
  • 新增 4 个测试:threading.Barrier 确定性验证并发、墙钟断言(<0.7s vs 串行 0.8s)、顺序保持、并发下单适配器错误不影响其他

验证:pytest 19 passed(基线 15+4)。遗留:未设 worker 硬上限(当前 4 个适配器足够,超 8 个时需加);适配器内部若有非线程安全全局状态需注意。

qiaobochi040726-source and others added 2 commits August 6, 2026 05:37
Run enabled adapters concurrently in a thread pool (IO/subprocess-bound,
CPU-light work) instead of sequentially. Worker count equals the number of
enabled adapters. Preserve config order by collecting futures in submission
order, and keep per-adapter error semantics (AdapterError / unexpected errors
become ToolRunResult error entries without aborting other adapters).

Adds tests proving concurrency (threading.Barrier + wall-clock < sequential
sum), config-order preservation, and that one failing adapter under
concurrency does not break the others.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parallelize adapter execution

2 participants