修复(登录任务): 取码失败自动换渠道,被跳过账号也落日志

- 登录先用人工设置的默认接口(当前 iframe):等码超时/发信失败后,
  同一账号自动切到另一条通道(iframe <-> wgapi)再试一轮,每个账号
  最多切一次;DOUYU_LOGIN_EMAIL_FALLBACK_API=off 可关闭
- 步骤 4/5 日志写明当前取码通道,切渠道时单独告警,页面可直接看到
- 配额/账号上限挡下的账号不再「凭空消失」:落一行 skipped 任务,
  日志写明未执行原因;界面新增「已跳过」状态、筛选与重试
- 停止、服务重启收敛、执行线程异常这几条路径也补单账号日志
- 修复刷新线程与收尾写库的覆盖竞态(旧快照会吃掉最后的失败原因)
- 补测试:渠道回退、跳过行与日志、日志真正落库
This commit is contained in:
yml
2026-11-25 19:04:38 +08:00
parent 5efe6b6949
commit 5dec234e3e
10 changed files with 732 additions and 60 deletions
+6 -2
View File
@@ -49,6 +49,8 @@ def test_must_bind_mobile_is_terminal(monkeypatch):
def test_email_code_timeout_stops_after_attempt_limit(monkeypatch):
"""每条发信通道只给 2 轮,两条都失败就收口,不会拖到 20 轮。"""
monkeypatch.delenv("DOUYU_LOGIN_EMAIL_FALLBACK_API", raising=False)
client = _login()
calls: list[int] = []
@@ -64,8 +66,10 @@ def test_email_code_timeout_stops_after_attempt_limit(monkeypatch):
assert result.success is False
assert result.code == "email_code_timeout"
assert len(calls) == client.EMAIL_CODE_MAX_ATTEMPTS
assert client.EMAIL_CODE_MAX_ATTEMPTS < 20
# 默认通道 + 自动切换后的另一条通道,各 2 轮
assert len(calls) == client.EMAIL_CODE_MAX_ATTEMPTS * 2
assert client.api.name == "iframe"
assert client.EMAIL_CODE_MAX_ATTEMPTS * 2 < 20
def test_retryable_error_still_retries(monkeypatch):