From 42c438656295be48e9b0a0bcb6a470dc7e595b3c Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Fri, 21 Mar 2025 19:28:49 +0800 Subject: [PATCH] fix: Add flush=True to print statements and improve task status check - Added flush=True to print statements for better real-time logging - Replaced single status check with a list of statuses to continue waiting - Defined constants for task status values for better code readability --- community/test/api/upload/command.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/community/test/api/upload/command.py b/community/test/api/upload/command.py index c38e35c..33876c1 100755 --- a/community/test/api/upload/command.py +++ b/community/test/api/upload/command.py @@ -48,13 +48,13 @@ def check_api_version(): return local_version = get_local_version() - print("检查被测服务器文档是否已经更新到最新版本...") + print("检查被测服务器文档是否已经更新到最新版本...", flush=True) while True: try: res = session.get(VERSION_URL) version = res.json()["version"] if version == local_version: - print(f"API 文档已更新,当前版本为 {version},开始上传 OpenAPI 文档...") + print(f"API 文档已更新,当前版本为 {version},开始上传 OpenAPI 文档...", flush=True) break else: print( @@ -126,7 +126,11 @@ def wait_for_task_done(task_id): res = session.get(f"{SERVER_URL}/tasks/{task_id}") data = res.json() status = data["status"] - if status == "succeeded": + + CREATED = "created" + RUNNING = "running" + WAITING = "waiting" + if status not in [CREATED, RUNNING, WAITING]: print("自动测试脚本执行完成!", flush=True) break else: