fix(worker): 优化连接池容量拆分、并发入队与事件写入

This commit is contained in:
yml
2026-11-29 11:24:35 +08:00
parent 1d92fa6d53
commit 2ea105a924
18 changed files with 956 additions and 207 deletions
+41
View File
@@ -2128,3 +2128,44 @@ def test_poll_bind_role_once_records_mismatched_cjm_and_ignores_bound_action_rol
assert "妎䏓" in task.message
assert task.result["last_mismatched_role"]["role_name"] == "妎朊"
assert [m["role_name"] for m in task.result["mismatched_roles"]] == ["妎朊"]
def test_mark_task_reuses_worker_session_without_nested_checkout(db, monkeypatch):
from web.backend import database as database_module
from web.backend.services.platform_fulfillment import service as pf_service
_, _, task = _fixtures(db, status="running")
task.task_type = "confirm_bind"
task.handbook_scope = "elite"
db.commit()
monkeypatch.setattr(
database_module,
"WorkerSessionLocal",
lambda: (_ for _ in ()).throw(AssertionError("收尾钩子不能再嵌套借用 WorkerSessionLocal")),
)
seen_dbs: list[tuple[str, object]] = []
monkeypatch.setattr(
pf_service,
"sync_task_from_binding_runner",
lambda session, *, douyu_task_id: seen_dbs.append(("sync", session)) or 0,
)
monkeypatch.setattr(
pf_service,
"verify_active_binding_for_douyu_task",
lambda session, *, douyu_task_id, actor_id=None: seen_dbs.append(("verify", session)) or None,
)
monkeypatch.setattr(
pf_service,
"refresh_active_exchange_eligibility_for_account",
lambda session, *, account_id, scope, actor_id=None: seen_dbs.append(("eligibility", session)) or None,
)
runner = DouyuBatchRunner(db, task.batch_id, "confirm_bind", close_db=False)
runner._mark_task(db, task, "success", "确认绑定成功")
assert seen_dbs == [
("sync", db),
("verify", db),
("eligibility", db),
]