refactor(fudai): 抽 _handle_in_fudai_detail 中重复的"清除任务数量标志"块到 clear_task_count_flag

_handle_in_fudai_detail 中有 11 处结构完全相同的"清除任务数量标志"
try/except 嵌套块(每处 12 行),统一抽到 clear_task_count_flag helper。
逻辑:set _fudai_detail_task_count_from_stage = None + log_kv("福袋详情",
"_handle_in_fudai_detail:清除任务数量标志", log_type="DEBUG")。

douyin_fudai.py: 3588 → 3460 行 (-128)
fudai_detail_helpers.py: 63 → 83 行

验证:
- pytest 1013 passed
- compile OK

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
CodexandClaude Opus 4.7 committed 2026-05-22 10:57:59 +08:00
1 parent d34e39ec9c
commit 9675df2cdb
2 files changed
+36 -144

No files matched your search

+16 -144
View File
@@ -2410,18 +2410,11 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
from douyin.core.fudai_modules.fudai_detail_helpers import (
clear_task_count_flag,
)
clear_task_count_flag(self)
# 步骤1结束计时
step1_elapsed = (time.time() - step1_start) * 1000
@@ -2487,18 +2480,7 @@ class fudai_analyse:
)
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -2759,18 +2741,7 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -2834,18 +2805,7 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -2864,18 +2824,7 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -2894,18 +2843,7 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -3027,18 +2965,7 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -3058,18 +2985,7 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -3113,18 +3029,7 @@ class fudai_analyse:
douyin_fudai_detail.close_fudai_detail(self)
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -3153,18 +3058,7 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -3211,18 +3105,7 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
@@ -3429,18 +3312,7 @@ class fudai_analyse:
pass
# 清除任务数量标志
try:
self._fudai_detail_task_count_from_stage = None
try:
self._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
clear_task_count_flag(self)
# 返回,让主循环只检测开奖结果,不执行其他操作
# 步骤4结束计时
@@ -5,6 +5,26 @@
from __future__ import annotations
def clear_task_count_flag(analyser) -> None:
"""清除任务数量标志(_fudai_detail_task_count_from_stage = None)。
在 _handle_in_fudai_detail 多个早返回路径中重复出现的清理逻辑,
统一抽到这里避免重复。
"""
try:
analyser._fudai_detail_task_count_from_stage = None
try:
analyser._log_kv(
"福袋详情",
"_handle_in_fudai_detail:清除任务数量标志",
log_type="DEBUG",
)
except Exception:
pass
except Exception:
pass
def handle_consecutive_failures_exceeded(analyser, max_consecutive_failures: int) -> None:
"""连续参与失败次数过多:关闭详情页、按需切换直播间、重置计数器。