From a51b3c4238ff8a70e7764f1a500de6e6a80ed540 Mon Sep 17 00:00:00 2001 From: iomgaa Date: Sat, 11 Jul 2026 12:11:48 -0400 Subject: [PATCH] fix(tools): validate concurrency params to prevent zero-semaphore deadlock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex 最终审查发现 video_concurrency=0 或 TREE_BUILD_API_CONCURRENCY=0 会创建永不放行的 Semaphore 导致整批挂死。追加 >= 1 校验,fail-fast 报错。 --- tools/build_trees.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/build_trees.py b/tools/build_trees.py index c5fbd67..9eab158 100644 --- a/tools/build_trees.py +++ b/tools/build_trees.py @@ -265,6 +265,10 @@ async def main_async(args: argparse.Namespace) -> None: assert videos_dir.is_dir(), f"视频目录不存在: {videos_dir}" api_concurrency = int(os.getenv("TREE_BUILD_API_CONCURRENCY", "16")) + if api_concurrency < 1: + raise ValueError(f"TREE_BUILD_API_CONCURRENCY 必须 >= 1,当前值: {api_concurrency}") + if args.video_concurrency < 1: + raise ValueError(f"--video-concurrency 必须 >= 1,当前值: {args.video_concurrency}") # Phase 1: 待建发现(progress + 完整性双重跳过) progress_path = Path(args.progress_path)