From 82dec6d40ccda0db71d9ed7c870bbb4290032449 Mon Sep 17 00:00:00 2001 From: dongchangxi <458593490@qq.com> Date: Sat, 11 Jan 2025 23:56:17 +0800 Subject: [PATCH] 1 --- yj_local_build/main_step1.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/yj_local_build/main_step1.py b/yj_local_build/main_step1.py index 0429b23..43bdea0 100644 --- a/yj_local_build/main_step1.py +++ b/yj_local_build/main_step1.py @@ -108,17 +108,11 @@ def detect_markers(psid, pid): # ######################################## process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - # 检查进程是否完成 - while True: - retcode = process.poll() # 返回值为None表示进程尚未结束 - if retcode is not None: - # 如果进程已经完成,打印退出状态码 - print(f"Process exited with code: {retcode}") - break - else: - print("Process is still running...") - time.sleep(1) # 每隔1秒检查一次 + # 使用 communicate() 等待进程完成 stdout, stderr = process.communicate() + # 获取进程的退出码 + exit_code = process.returncode + print(f"Process exited with code: {exit_code}") print(f"Output: {stdout.decode()}") print(f"Error: {stderr.decode()}") print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")