From f61f74a4cd7857cf0efe403e6308368bfd853bca Mon Sep 17 00:00:00 2001 From: Peanut Date: Thu, 21 May 2026 22:19:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=83=A8=E7=BD=B2=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=AD=90=E8=BF=9B=E7=A8=8B=E8=BE=93=E5=87=BA=E8=A2=ABPython?= =?UTF-8?q?=E7=BC=93=E5=86=B2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 子进程Python脚本运行时,Python自动缓冲stdout(因为检测到非TTY)。 设置PYTHONUNBUFFERED=1环境变量,确保所有Python子进程实时输出。 Co-Authored-By: Claude Opus 4.7 --- deploy.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deploy.py b/deploy.py index 554ecf3..c8f4941 100644 --- a/deploy.py +++ b/deploy.py @@ -82,17 +82,20 @@ def log_section(msg): def run_command(cmd, cwd=None, timeout=120, capture=True): """执行本地命令""" + # 设置 PYTHONUNBUFFERED=1 确保 Python 子进程不缓冲 stdout + env = os.environ.copy() + env['PYTHONUNBUFFERED'] = '1' try: if capture: result = subprocess.run( - cmd, shell=True, cwd=cwd, + cmd, shell=True, cwd=cwd, env=env, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=timeout ) return result.returncode == 0, result.stdout.strip(), result.stderr.strip() else: result = subprocess.run( - cmd, shell=True, cwd=cwd, timeout=timeout + cmd, shell=True, cwd=cwd, env=env, timeout=timeout ) return result.returncode == 0, "", "" except subprocess.TimeoutExpired: