auto-sync: 2026-05-06 06:28:08

This commit is contained in:
cfdaily
2026-05-06 06:28:08 +08:00
parent be42867058
commit f374aa1a13
+12
View File
@@ -265,8 +265,20 @@ def main():
stats = {"ok": 0, "skipped": 0, "failed": 0, "rows": 0}
t_start = time.time()
RELOGIN_EVERY = 400 # 每400只重新登录BaoStock,防止连接断开
for i, code in enumerate(todo):
# 定期重新登录保持连接
if i > 0 and i % RELOGIN_EVERY == 0:
bs.logout()
time.sleep(2)
lg = bs.login()
if lg.error_code != "0":
logger.error("BaoStock重连失败: %s,等待30秒", lg.error_msg)
time.sleep(30)
lg = bs.login()
logger.info("BaoStock重连 @ %d/%d", i, len(todo))
try:
status, total_rows = backfill_one(code, start_date, end_date, args.force)
except Exception as e: