Cap export-task poll loops at 5min to avoid infinite hang
顺心/中通/韵达/安能 的导出任务轮询循环原本只在"本批任务全部完成"时 退出,无任何时间上限:任务卡在生成中、或因时钟偏移没落进 40s 容差窗口 匹配不上时,会无限轮询、流程永不返回,连 with_retry 都没机会触发。 给这 5 处轮询加 300s deadline,超时即 raise → 流程返回 False → 触发 已有的重置重试机制。把"永久挂死"变成"有界失败→自动重试"。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import yaml
|
||||
from datetime import datetime, timedelta
|
||||
import pandas as pd
|
||||
@@ -249,7 +250,14 @@ def shunxin_expected_download_impl(page):
|
||||
|
||||
# 7. 轮询任务状态
|
||||
print(">> 列表已加载,开始匹配并检查任务状态...")
|
||||
poll_deadline = (
|
||||
time.monotonic() + 300
|
||||
) # 5 分钟上限:任务卡死/匹配不上时超时失败,交由上层重置重试
|
||||
while True:
|
||||
if time.monotonic() > poll_deadline:
|
||||
raise RuntimeError(
|
||||
"轮询导出任务超时(5 分钟未全部完成/匹配),疑似任务卡死"
|
||||
)
|
||||
rows = page.locator(".ant-table-tbody > tr.ant-table-row")
|
||||
row_count = rows.count()
|
||||
pending_tasks = 0
|
||||
@@ -506,7 +514,14 @@ def shunxin_actual_download_impl(page):
|
||||
|
||||
# 6. 轮询任务状态
|
||||
print(">> 列表已加载,开始匹配并检查任务状态...")
|
||||
poll_deadline = (
|
||||
time.monotonic() + 300
|
||||
) # 5 分钟上限:任务卡死/匹配不上时超时失败,交由上层重置重试
|
||||
while True:
|
||||
if time.monotonic() > poll_deadline:
|
||||
raise RuntimeError(
|
||||
"轮询导出任务超时(5 分钟未全部完成/匹配),疑似任务卡死"
|
||||
)
|
||||
rows = page.locator(".ant-table-tbody > tr.ant-table-row")
|
||||
row_count = rows.count()
|
||||
pending_tasks = 0
|
||||
|
||||
Reference in New Issue
Block a user