auto-sync: 2026-05-05 00:03:27

This commit is contained in:
cfdaily
2026-05-05 00:03:27 +08:00
parent ff49ac789a
commit 3604e69442
+29 -5
View File
@@ -401,21 +401,45 @@ def run_daily_update(codes: List[str]) -> dict:
continue continue
data = None data = None
source_used = ""
first_attempt_failed = False first_attempt_failed = False
# 主源:东方财富(amount真实,可拿多年历史)
for attempt in range(MAX_RETRIES): for attempt in range(MAX_RETRIES):
try: try:
data = fetch_tencent_daily(code, next_day, today) data = fetch_eastmoney_daily(code, next_day, today)
if data is not None: if data is not None:
source_used = "eastmoney"
break break
if attempt == 0: if attempt == 0:
first_attempt_failed = True first_attempt_failed = True
except Exception as e: except Exception:
if attempt == 0: if attempt == 0:
first_attempt_failed = True first_attempt_failed = True
if attempt < MAX_RETRIES - 1: if attempt < MAX_RETRIES - 1:
time.sleep(1) time.sleep(2)
else:
logger.debug("日线 %s 失败: %s", code, e) # 备源:腾讯(amount有时为0
if data is None:
first_attempt_failed_backup = False
for attempt in range(MAX_RETRIES):
try:
data = fetch_tencent_daily(code, next_day, today)
if data is not None:
source_used = "tencent"
break
if attempt == 0:
first_attempt_failed_backup = True
except Exception:
if attempt == 0:
first_attempt_failed_backup = True
if attempt < MAX_RETRIES - 1:
time.sleep(1)
# 只有两个源都首次失败才算全局失败
if first_attempt_failed and first_attempt_failed_backup:
first_attempt_failed = True
else:
first_attempt_failed = False
# 全局源不可用检测 # 全局源不可用检测
if not health.report(code, first_attempt_failed and data is None): if not health.report(code, first_attempt_failed and data is None):