增加重复课程学习重试逻辑
This commit is contained in:
+25
-3
@@ -113,21 +113,43 @@ token.txt 说明:
|
|||||||
verify_ssl=args.verify_ssl,
|
verify_ssl=args.verify_ssl,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
max_retries = 3
|
||||||
|
for attempt in range(max_retries + 1):
|
||||||
try:
|
try:
|
||||||
success = autopilot.run()
|
success = autopilot.run()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"\n❌ 课程执行异常: {e}")
|
||||||
|
if attempt < max_retries:
|
||||||
|
print(f" 第 {attempt + 1}/{max_retries} 次重试...\n")
|
||||||
|
autopilot = EFCourseAutopilot(
|
||||||
|
token=token,
|
||||||
|
skip_on_fail=True,
|
||||||
|
verify_ssl=args.verify_ssl,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
total_fail += 1
|
||||||
|
break
|
||||||
|
|
||||||
if autopilot.repeat_detected:
|
if autopilot.repeat_detected:
|
||||||
|
if attempt < max_retries:
|
||||||
|
print(f"\n⚠️ 检测到重复,第 {attempt + 1}/{max_retries} 次重试...\n")
|
||||||
|
autopilot = EFCourseAutopilot(
|
||||||
|
token=token,
|
||||||
|
skip_on_fail=True,
|
||||||
|
verify_ssl=args.verify_ssl,
|
||||||
|
)
|
||||||
|
continue
|
||||||
print("\n⚠️ 检测到重复课程,自动循环终止。")
|
print("\n⚠️ 检测到重复课程,自动循环终止。")
|
||||||
print(f" 「{random.choice(QUOTES)}」 —— 凯特莎")
|
print(f" 「{random.choice(QUOTES)}」 —— 凯特莎")
|
||||||
print(" 请手动完成此课程,完成后重新运行本程序继续后续课程。")
|
print(" 请手动完成此课程,完成后重新运行本程序继续后续课程。")
|
||||||
total_fail += 1
|
total_fail += 1
|
||||||
break
|
break
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
total_success += 1
|
total_success += 1
|
||||||
else:
|
else:
|
||||||
total_fail += 1
|
total_fail += 1
|
||||||
except Exception as e:
|
break
|
||||||
print(f"\n❌ 课程执行异常: {e}")
|
|
||||||
total_fail += 1
|
|
||||||
|
|
||||||
elapsed = time.time() - start_time
|
elapsed = time.time() - start_time
|
||||||
print(f"\n{'#' * 60}")
|
print(f"\n{'#' * 60}")
|
||||||
|
|||||||
Reference in New Issue
Block a user