From 52505e9aff1901db583c2b0155dde5ac30cc0bf0 Mon Sep 17 00:00:00 2001 From: Ying-Li Niu <64801511@qq.com> Date: Thu, 11 Jun 2026 22:48:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(compute):=20=E4=BF=AE=E5=A4=8D=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=9D=A1=E8=B7=B3=E5=8F=98=EF=BC=8820%=E2=86=92100%?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原因:外部引擎 stdout 管道缓存,Python 每 0.2s 读一行, 引擎结束时管道中大量库存进度消息没被用于更新进度条。 修复: 1. 子进程退出时扫描残留 stdout 中的 progress 消息并更新 pbar 2. sleep 从 0.2s 降到 0.05s,提高读取频率 --- compute.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compute.py b/compute.py index 878255c..975f858 100644 --- a/compute.py +++ b/compute.py @@ -775,8 +775,14 @@ def run_engine(engine, input_dir, output_dir, config): _r = _r.strip() if _r: _engine_lines.append(_r) + # 读取残留在管道中的进度消息,避免 20%→100% 跳变 + _prog_match = re.search(r'progress:\s*(\d+)/(\d+)', _r) + if _pbar is not None and _prog_match: + _p_done = min(int(_prog_match.group(1)), total_steps) + _pbar.n = max(_pbar.n, _p_done) + if _pbar is not None: _pbar.refresh() break - time.sleep(0.2) + time.sleep(0.05) finally: if _pbar is not None: _pbar.n = total_steps