type: 收敛测试 schemas 与协议层类型
This commit is contained in:
@@ -21,7 +21,13 @@ from .douyu_runner_xpd import XpdMixin
|
||||
|
||||
|
||||
class DouyuBatchRunner(
|
||||
DouyuBatchRunnerCore, BindMixin, ManualMixin, GoldMixin, DonateMixin, GoodsMixin, XpdMixin,
|
||||
DouyuBatchRunnerCore,
|
||||
BindMixin,
|
||||
ManualMixin,
|
||||
GoldMixin,
|
||||
DonateMixin,
|
||||
GoodsMixin,
|
||||
XpdMixin,
|
||||
):
|
||||
"""批量执行斗鱼活动任务(功能域 Mixin 聚合 + 批次调度)。"""
|
||||
|
||||
@@ -43,13 +49,18 @@ class DouyuBatchRunner(
|
||||
self._started += 1
|
||||
current = self._started
|
||||
|
||||
self._push_log("info", f"[{current}/{total}] 开始: {self._account_name(account)}")
|
||||
self._push_log(
|
||||
"info", f"[{current}/{total}] 开始: {self._account_name(account)}"
|
||||
)
|
||||
login_task = latest_success_login_task(worker_db, account.id)
|
||||
cookie = login_task.cookie if login_task else ""
|
||||
if not cookie:
|
||||
self._mark_task(worker_db, task, "failed", "账号没有成功登录 Cookie")
|
||||
self._push_log("warning", f"[{current}] {self._account_name(account)} 无 Cookie")
|
||||
self._push_log(
|
||||
"warning", f"[{current}] {self._account_name(account)} 无 Cookie"
|
||||
)
|
||||
return
|
||||
assert login_task is not None
|
||||
|
||||
cookie_check = check_douyu_cookie(cookie)
|
||||
login_task.ck_check_status = "valid" if cookie_check["valid"] else "invalid"
|
||||
@@ -62,7 +73,9 @@ class DouyuBatchRunner(
|
||||
if not cookie_check["valid"]:
|
||||
message = f"Cookie 已失效,请重新登录:{cookie_check['message']}"
|
||||
self._mark_task(worker_db, task, "failed", message)
|
||||
self._push_log("warning", f"[{current}] {self._account_name(account)} {message}")
|
||||
self._push_log(
|
||||
"warning", f"[{current}] {self._account_name(account)} {message}"
|
||||
)
|
||||
return
|
||||
|
||||
update_account_profile_from_cookie(account, cookie)
|
||||
@@ -109,7 +122,9 @@ class DouyuBatchRunner(
|
||||
return
|
||||
|
||||
handler(worker_db, task, account, cookie, config)
|
||||
self._push_log("success", f"[{current}] {self._account_name(account)} {task.message}")
|
||||
self._push_log(
|
||||
"success", f"[{current}] {self._account_name(account)} {task.message}"
|
||||
)
|
||||
except DouyuActivityError as exc:
|
||||
if "task" in locals() and task:
|
||||
self._mark_task(worker_db, task, "failed", str(exc))
|
||||
@@ -128,7 +143,9 @@ class DouyuBatchRunner(
|
||||
config = self._config_info(self.db)
|
||||
tasks = (
|
||||
self.db.query(DouyuTask)
|
||||
.filter(DouyuTask.batch_id == self.batch_id, DouyuTask.status == "planned")
|
||||
.filter(
|
||||
DouyuTask.batch_id == self.batch_id, DouyuTask.status == "planned"
|
||||
)
|
||||
.order_by(DouyuTask.id.asc())
|
||||
.all()
|
||||
)
|
||||
@@ -150,7 +167,9 @@ class DouyuBatchRunner(
|
||||
for task in tasks:
|
||||
if self._stop.is_set():
|
||||
break
|
||||
futures.append(executor.submit(self._execute_one, task.id, config, total))
|
||||
futures.append(
|
||||
executor.submit(self._execute_one, task.id, config, total)
|
||||
)
|
||||
for future in as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
|
||||
Reference in New Issue
Block a user