REFINE 优化任务查询逻辑,改进日志记录以增强可读性
This commit is contained in:
parent
bbd0c5325e
commit
770562a569
|
|
@ -306,16 +306,17 @@ class ModalMidJourneyGenerateImage:
|
||||||
raise Exception("生成失败, 可能因为风控")
|
raise Exception("生成失败, 可能因为风控")
|
||||||
job_id = job_resp["data"]
|
job_id = job_resp["data"]
|
||||||
start_time = time()
|
start_time = time()
|
||||||
for _ in range(0, timeout // interval, interval):
|
while start_time + timeout > time():
|
||||||
logger.info(f"已等待 {time() - start_time} 秒,{interval} 秒后查询...")
|
logger.info(f"已等待 {(int(time() - start_time))} 秒,{interval} 秒后查询...")
|
||||||
sleep(interval)
|
sleep(interval)
|
||||||
logger.info(f"查询结果 {job_id}")
|
logger.info(f"开始查询结果 {job_id}")
|
||||||
resp = send_request(
|
resp = send_request(
|
||||||
"get",
|
"get",
|
||||||
f"https://{endpoint}/api/custom/task/status?task_id={job_id}",
|
f"https://{endpoint}/api/custom/task/status?task_id={job_id}",
|
||||||
timeout=30,
|
timeout=30,
|
||||||
)
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
|
logger.info(f"查询结果 {resp.json()['msg']}")
|
||||||
if resp.json()["status"] == "running":
|
if resp.json()["status"] == "running":
|
||||||
logger.info(f"任务正在运行 {job_id}")
|
logger.info(f"任务正在运行 {job_id}")
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue