diff --git a/docker-compose.yml b/docker-compose.yml index a83ee5b..612b17d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,26 +47,26 @@ services: - WORKER_DB_POOL_SIZE=${WORKER_DB_POOL_SIZE:-12} - WORKER_DB_MAX_OVERFLOW=${WORKER_DB_MAX_OVERFLOW:-4} - WORKER_DB_POOL_TIMEOUT=${WORKER_DB_POOL_TIMEOUT:-30} - - DOUYU_BATCH_CREATE_CONCURRENCY=${DOUYU_BATCH_CREATE_CONCURRENCY:-2} - - DOUYU_BATCH_TASK_CONCURRENCY=${DOUYU_BATCH_TASK_CONCURRENCY:-5} - - DOUYU_PAYMENT_QR_CONCURRENCY=${DOUYU_PAYMENT_QR_CONCURRENCY:-10} - - DOUYU_MAX_ACTIVE_BATCHES=${DOUYU_MAX_ACTIVE_BATCHES:-10} - - DOUYU_MAX_ACTIVE_OVERVIEW_TASKS=${DOUYU_MAX_ACTIVE_OVERVIEW_TASKS:-5} - - TASK_LANE_BATCH_COORDINATOR_WORKERS=${TASK_LANE_BATCH_COORDINATOR_WORKERS:-2} - - TASK_LANE_BATCH_COORDINATOR_MAX_IN_FLIGHT=${TASK_LANE_BATCH_COORDINATOR_MAX_IN_FLIGHT:-2} - - TASK_LANE_INTERACTIVE_BINDING_WORKERS=${TASK_LANE_INTERACTIVE_BINDING_WORKERS:-3} - - TASK_LANE_BINDING_POLL_WORKERS=${TASK_LANE_BINDING_POLL_WORKERS:-6} - - TASK_LANE_BINDING_POLL_MAX_IN_FLIGHT=${TASK_LANE_BINDING_POLL_MAX_IN_FLIGHT:-6} - - TASK_LANE_LOGIN_WORKERS=${TASK_LANE_LOGIN_WORKERS:-4} - - TASK_LANE_ACCOUNT_CHECK_WORKERS=${TASK_LANE_ACCOUNT_CHECK_WORKERS:-4} - - TASK_LANE_ACCOUNT_SYNC_WORKERS=${TASK_LANE_ACCOUNT_SYNC_WORKERS:-3} - - TASK_LANE_OVERVIEW_QUERY_WORKERS=${TASK_LANE_OVERVIEW_QUERY_WORKERS:-5} - - TASK_LANE_QUERY_BATCH_WORKERS=${TASK_LANE_QUERY_BATCH_WORKERS:-3} - - TASK_LANE_PAYMENT_QR_WORKERS=${TASK_LANE_PAYMENT_QR_WORKERS:-10} - - TASK_LANE_PAYMENT_POLL_WORKERS=${TASK_LANE_PAYMENT_POLL_WORKERS:-3} - - TASK_LANE_PAYMENT_POLL_MAX_IN_FLIGHT=${TASK_LANE_PAYMENT_POLL_MAX_IN_FLIGHT:-3} - - TASK_LANE_OPS_WRITE_WORKERS=${TASK_LANE_OPS_WRITE_WORKERS:-2} - - DOUYU_MAX_ACTIVE_TASKS=${DOUYU_MAX_ACTIVE_TASKS:-250} + - DOUYU_BATCH_CREATE_CONCURRENCY=${DOUYU_BATCH_CREATE_CONCURRENCY:-4} + - DOUYU_BATCH_TASK_CONCURRENCY=${DOUYU_BATCH_TASK_CONCURRENCY:-10} + - DOUYU_PAYMENT_QR_CONCURRENCY=${DOUYU_PAYMENT_QR_CONCURRENCY:-15} + - DOUYU_MAX_ACTIVE_BATCHES=${DOUYU_MAX_ACTIVE_BATCHES:-25} + - DOUYU_MAX_ACTIVE_OVERVIEW_TASKS=${DOUYU_MAX_ACTIVE_OVERVIEW_TASKS:-10} + - TASK_LANE_BATCH_COORDINATOR_WORKERS=${TASK_LANE_BATCH_COORDINATOR_WORKERS:-6} + - TASK_LANE_BATCH_COORDINATOR_MAX_IN_FLIGHT=${TASK_LANE_BATCH_COORDINATOR_MAX_IN_FLIGHT:-6} + - TASK_LANE_INTERACTIVE_BINDING_WORKERS=${TASK_LANE_INTERACTIVE_BINDING_WORKERS:-6} + - TASK_LANE_BINDING_POLL_WORKERS=${TASK_LANE_BINDING_POLL_WORKERS:-12} + - TASK_LANE_BINDING_POLL_MAX_IN_FLIGHT=${TASK_LANE_BINDING_POLL_MAX_IN_FLIGHT:-12} + - TASK_LANE_LOGIN_WORKERS=${TASK_LANE_LOGIN_WORKERS:-8} + - TASK_LANE_ACCOUNT_CHECK_WORKERS=${TASK_LANE_ACCOUNT_CHECK_WORKERS:-8} + - TASK_LANE_ACCOUNT_SYNC_WORKERS=${TASK_LANE_ACCOUNT_SYNC_WORKERS:-6} + - TASK_LANE_OVERVIEW_QUERY_WORKERS=${TASK_LANE_OVERVIEW_QUERY_WORKERS:-10} + - TASK_LANE_QUERY_BATCH_WORKERS=${TASK_LANE_QUERY_BATCH_WORKERS:-10} + - TASK_LANE_PAYMENT_QR_WORKERS=${TASK_LANE_PAYMENT_QR_WORKERS:-12} + - TASK_LANE_PAYMENT_POLL_WORKERS=${TASK_LANE_PAYMENT_POLL_WORKERS:-6} + - TASK_LANE_PAYMENT_POLL_MAX_IN_FLIGHT=${TASK_LANE_PAYMENT_POLL_MAX_IN_FLIGHT:-6} + - TASK_LANE_OPS_WRITE_WORKERS=${TASK_LANE_OPS_WRITE_WORKERS:-6} + - DOUYU_MAX_ACTIVE_TASKS=${DOUYU_MAX_ACTIVE_TASKS:-500} - DOUYU_PROBE_CACHE_SECONDS=${DOUYU_PROBE_CACHE_SECONDS:-30} - DOUYU_COLLAB_VERIFY_BATCH_INTERVAL_SECONDS=${DOUYU_COLLAB_VERIFY_BATCH_INTERVAL_SECONDS:-0.2} # JWT 密钥(生产环境务必修改,可用 python -c "import secrets; print(secrets.token_urlsafe(32))" 生成) @@ -116,7 +116,7 @@ services: - BACKGROUND_RUNTIME_IN_SEPARATE_PROCESS=${BACKGROUND_RUNTIME_IN_SEPARATE_PROCESS:-true} - EXECUTION_WORKER_LANES=${EXECUTION_WORKER_LANES:-auth,fulfillment} - BACKGROUND_CONTROL_PLANE_ENABLED=${BACKGROUND_CONTROL_PLANE_ENABLED:-true} - - EXECUTION_WORKER_MAX_JOBS=${EXECUTION_WORKER_MAX_JOBS:-2} + - EXECUTION_WORKER_MAX_JOBS=${EXECUTION_WORKER_MAX_JOBS:-6} - EXECUTION_WORKER_POLL_SECONDS=${EXECUTION_WORKER_POLL_SECONDS:-1} - EXECUTION_JOB_LEASE_SECONDS=${EXECUTION_JOB_LEASE_SECONDS:-90} # order_site 订单只读库(P0 订单读取适配层用;未配置时适配层整体降级) diff --git a/tests/test_douyu_task_concurrency.py b/tests/test_douyu_task_concurrency.py index 7f6b162..312dd43 100644 --- a/tests/test_douyu_task_concurrency.py +++ b/tests/test_douyu_task_concurrency.py @@ -1,4 +1,5 @@ import inspect +import os from datetime import UTC, datetime, timedelta import pytest @@ -489,9 +490,7 @@ def test_batch_launcher_defers_database_session_to_worker(monkeypatch): monkeypatch.setattr( douyu_batch_launcher, "WorkerSessionLocal", - lambda: (_ for _ in ()).throw( - AssertionError("队列阶段不能创建数据库 Session") - ), + lambda: (_ for _ in ()).throw(AssertionError("队列阶段不能创建数据库 Session")), ) monkeypatch.setattr(douyu_batch_launcher, "submit", fake_submit) @@ -962,9 +961,7 @@ def test_confirm_bind_maps_cooldown_and_keeps_old_role( account.game_name = old_role account.role_bind_status = "bound" db.commit() - can_change_time = int( - (datetime.now(UTC) + timedelta(days=2)).timestamp() - ) + can_change_time = int((datetime.now(UTC) + timedelta(days=2)).timestamp()) old_bound = { "act_alias": "20260120QYOOB", "role_name": old_role, @@ -1044,9 +1041,7 @@ def test_confirm_bind_maps_cooldown_and_keeps_old_role( assert account.role_bind_status == "bound" -def test_qr_preflight_accepts_existing_action_alias_pending_from_har( - db, monkeypatch -): +def test_qr_preflight_accepts_existing_action_alias_pending_from_har(db, monkeypatch): """2026-11-22 成功 HAR:已有 bindAct=0 角色无需等新一轮状态变化。""" _, account, task = _fixtures(db, status="running") role = "忧郁情潇藏心中" @@ -1110,9 +1105,7 @@ def test_qr_preflight_accepts_existing_action_alias_pending_from_har( assert task.result["bind_decision"]["reason"] == "existing_actionable_pending" -def test_qr_preflight_keeps_bound_role_waiting_for_new_scan_transition( - db, monkeypatch -): +def test_qr_preflight_keeps_bound_role_waiting_for_new_scan_transition(db, monkeypatch): """历史 bindAct=1 + needBindAct=1 不能直接进入待确认。""" _, account, task = _fixtures(db, status="running") role = "你哥奢皇" @@ -1181,15 +1174,11 @@ def test_qr_preflight_keeps_bound_role_waiting_for_new_scan_transition( assert action_decision["reason"] == "already_bound" -def test_qr_preflight_blocks_platform_account_change_cooldown_from_har( - db, monkeypatch -): +def test_qr_preflight_blocks_platform_account_change_cooldown_from_har(db, monkeypatch): """2026-11-22 失败 HAR:canChangeTime 限制当前斗鱼号,发码前就必须拦截。""" _, account, task = _fixtures(db, status="running") role = "狗鼻子弗尼亚bd" - can_change_time = int( - (datetime.now(UTC) + timedelta(days=2)).timestamp() - ) + can_change_time = int((datetime.now(UTC) + timedelta(days=2)).timestamp()) activity = { "act_alias": "20260120QYOOB", "role_name": role, @@ -1252,9 +1241,7 @@ def test_qr_preflight_blocks_platform_account_change_cooldown_from_har( assert account.role_bind_status == "bound" -def test_binding_poll_accepts_existing_action_alias_pending_same_role( - db, monkeypatch -): +def test_binding_poll_accepts_existing_action_alias_pending_same_role(db, monkeypatch): """活动 alias 的同名待确认角色不能被 legacy(cjm) 的旧快照压掉。""" _, account, task = _fixtures(db, status="running") role = "忧郁情潇藏心中" @@ -1322,17 +1309,14 @@ def test_binding_poll_accepts_existing_action_alias_pending_same_role( assert task.result["bind_decision"]["alias"] == "20260120QYOOB" assert task.result["bind_decision"]["reason"] == "same_alias_after_bound_transition" assert { - row["alias"]: row["reason"] - for row in task.result["bind_candidate_decisions"] + row["alias"]: row["reason"] for row in task.result["bind_candidate_decisions"] } == { "cjm": "same_role_stale", "20260120QYOOB": "same_alias_after_bound_transition", } -def test_binding_poll_accepts_unchanged_existing_action_alias_pending( - db, monkeypatch -): +def test_binding_poll_accepts_unchanged_existing_action_alias_pending(db, monkeypatch): """2026-11-22 成功 HAR:已有动作 alias pending 不要求本轮状态变化。""" _, account, task = _fixtures(db, status="running") role = "只为爱杰宝" @@ -1404,9 +1388,7 @@ def test_binding_poll_accepts_unchanged_existing_action_alias_pending( assert task.result["bind_decision"]["reason"] == "existing_actionable_pending" -def test_workbench_rebind_detects_new_cjm_scan_without_expected_role( - db, monkeypatch -): +def test_workbench_rebind_detects_new_cjm_scan_without_expected_role(db, monkeypatch): """HAR 11.22 用户中心换绑:已绑定账号发码后只有 cjm 变化,工作台轮询也必须识别。""" _, account, task = _fixtures(db, status="running") bound_activity = { @@ -1586,9 +1568,7 @@ def test_binding_poll_empty_baseline_preserves_need_bind_act_on_candidates( assert pending_binding_role_from_result(task.result) == "欧美真心" -def test_binding_poll_preserves_concurrently_written_expected_role( - db, monkeypatch -): +def test_binding_poll_preserves_concurrently_written_expected_role(db, monkeypatch): """轮询写回 task.result 时,不能覆盖客户并发提交进来的 expected_role_name。""" _, account, task = _fixtures(db, status="running") task.queue_lane = "binding_poll" @@ -1807,47 +1787,51 @@ def test_active_batch_budget_returns_429(monkeypatch): assert exc_info.value.status_code == 429 -def test_douyu_batch_request_allows_ten_workers_for_payment_qr(): +def test_douyu_batch_request_allows_fifteen_workers_for_payment_qr(): req = DouyuTaskBatchRequest( account_ids=[1], task_type="create_gold_qr", handbook_scope="elite", - concurrency=10, + concurrency=15, ) - assert req.concurrency == 10 + assert req.concurrency == 15 with pytest.raises(ValidationError): DouyuTaskBatchRequest( account_ids=[1], task_type="create_gold_qr", handbook_scope="elite", - concurrency=11, + concurrency=16, ) -def test_batch_task_concurrency_is_capped_at_five(): - assert douyu_concurrency.clamp_batch_task_concurrency(20) == 5 - assert douyu_concurrency.clamp_douyu_task_concurrency("query_points", 20) == 5 - assert douyu_concurrency.clamp_douyu_task_concurrency("create_gold_qr", 20) == 10 +def test_batch_task_concurrency_is_capped_at_ten(monkeypatch): + monkeypatch.setattr(douyu_concurrency, "DOUYU_BATCH_TASK_CONCURRENCY", 10) + monkeypatch.setattr(douyu_concurrency, "DOUYU_PAYMENT_QR_CONCURRENCY", 15) + assert douyu_concurrency.clamp_batch_task_concurrency(20) == 10 + assert douyu_concurrency.clamp_douyu_task_concurrency("query_points", 20) == 10 + assert douyu_concurrency.clamp_douyu_task_concurrency("create_gold_qr", 20) == 15 -def test_runner_applies_task_specific_concurrency(db): +def test_runner_applies_task_specific_concurrency(db, monkeypatch): + monkeypatch.setattr(douyu_concurrency, "DOUYU_BATCH_TASK_CONCURRENCY", 10) + monkeypatch.setattr(douyu_concurrency, "DOUYU_PAYMENT_QR_CONCURRENCY", 15) payment = DouyuBatchRunner( db, "payment-batch", "create_gold_qr", - concurrency=10, + concurrency=15, close_db=False, ) overview = DouyuBatchRunner( db, "overview-batch", "query_account_overview", - concurrency=10, + concurrency=15, close_db=False, ) - assert payment.concurrency == 10 - assert overview.concurrency == 5 + assert payment.concurrency == 15 + assert overview.concurrency == 10 def test_douyu_lanes_separate_interactive_query_payment_and_writes(): @@ -1855,10 +1839,13 @@ def test_douyu_lanes_separate_interactive_query_payment_and_writes(): assert douyu_lane_for_task("query_account_overview") == TaskLane.OVERVIEW_QUERY assert douyu_lane_for_task("create_gold_qr") == TaskLane.PAYMENT_QR assert douyu_lane_for_task("exchange_goods") == TaskLane.OPS_WRITE - assert _DEFAULT_WORKERS[TaskLane.PAYMENT_QR] == 10 - assert _DEFAULT_WORKERS[TaskLane.PAYMENT_POLL] == 3 - assert _DEFAULT_WORKERS[TaskLane.OVERVIEW_QUERY] == 5 - assert _DEFAULT_WORKERS[TaskLane.BINDING_POLL] == 6 + assert _DEFAULT_WORKERS[TaskLane.PAYMENT_QR] == 12 + assert _DEFAULT_WORKERS[TaskLane.PAYMENT_POLL] == 6 + expected_overview = max(1, int(os.getenv("DOUYU_MAX_ACTIVE_OVERVIEW_TASKS") or 10)) + assert _DEFAULT_WORKERS[TaskLane.OVERVIEW_QUERY] == expected_overview + assert _DEFAULT_WORKERS[TaskLane.QUERY_BATCH] == 10 + assert _DEFAULT_WORKERS[TaskLane.OPS_WRITE] == 6 + assert _DEFAULT_WORKERS[TaskLane.BINDING_POLL] == 12 def test_slim_task_result_removes_debug_payloads(): diff --git a/web/backend/schemas.py b/web/backend/schemas.py index 95c6b01..611c5ee 100644 --- a/web/backend/schemas.py +++ b/web/backend/schemas.py @@ -1888,7 +1888,7 @@ class DouyuTaskBatchRequest(BaseModel): account_ids: list[int] task_type: str handbook_scope: str = Field(..., pattern="^(elite|esports|peace)$") - concurrency: int = Field(3, ge=1, le=10) + concurrency: int = Field(5, ge=1, le=15) payload: dict[str, Any] = Field(default_factory=dict) platform_task_id: int | None = Field(None, gt=0) recharge_confirmation_token: str | None = Field(None, max_length=64) diff --git a/web/backend/services/automation/__init__.py b/web/backend/services/automation/__init__.py index 1a7afdf..bb976f7 100644 --- a/web/backend/services/automation/__init__.py +++ b/web/backend/services/automation/__init__.py @@ -226,7 +226,7 @@ def register_default_jobs() -> None: # relogin_next_at 的退避表决定);批次小、跑得慢,单轮 10 条。 interval_seconds=6 * 3600, batch_size=10, - concurrency=3, + concurrency=5, run=run_ck_relogin, ) ) @@ -253,7 +253,7 @@ def register_default_jobs() -> None: # 反推,吞吐 40 条/分钟,够 6 小时内覆盖一遍(规划 §7.3)。 interval_seconds=6 * 3600, batch_size=200, - concurrency=5, + concurrency=8, run=run_ck_health, ) ) diff --git a/web/backend/services/automation/scheduler.py b/web/backend/services/automation/scheduler.py index 64e23f4..8a4d37e 100644 --- a/web/backend/services/automation/scheduler.py +++ b/web/backend/services/automation/scheduler.py @@ -74,7 +74,7 @@ _REGISTRY: dict[str, JobSpec] = {} #: 同时最多几个作业在跑。作业之间互不依赖,并行是为了**慢作业不挡住快作业** #: (以前串行:一个作业跑 4 分钟,CK 巡检就得等 4 分钟)。 -_JOB_MAX_WORKERS = 2 +_JOB_MAX_WORKERS = 3 #: 运行间隔的下限:太短会变成忙轮询,没有意义 MIN_RUN_INTERVAL_SECONDS = 30 diff --git a/web/backend/services/douyu_batch_launcher.py b/web/backend/services/douyu_batch_launcher.py index 468d584..6f2dd5d 100644 --- a/web/backend/services/douyu_batch_launcher.py +++ b/web/backend/services/douyu_batch_launcher.py @@ -25,9 +25,9 @@ def _env_positive_int(name: str, default: int) -> int: DOUYU_BATCH_CREATE_CONCURRENCY = _env_positive_int( "DOUYU_BATCH_CREATE_CONCURRENCY", - 2, + 4, ) -DOUYU_MAX_ACTIVE_BATCHES = _env_positive_int("DOUYU_MAX_ACTIVE_BATCHES", 10) +DOUYU_MAX_ACTIVE_BATCHES = _env_positive_int("DOUYU_MAX_ACTIVE_BATCHES", 25) def _run_batch( diff --git a/web/backend/services/douyu_concurrency.py b/web/backend/services/douyu_concurrency.py index 8650317..7d6752f 100644 --- a/web/backend/services/douyu_concurrency.py +++ b/web/backend/services/douyu_concurrency.py @@ -19,11 +19,11 @@ def _env_positive_int(name: str, default: int) -> int: DOUYU_BATCH_TASK_CONCURRENCY = _env_positive_int( "DOUYU_BATCH_TASK_CONCURRENCY", - 5, + 10, ) DOUYU_PAYMENT_QR_CONCURRENCY = _env_positive_int( "DOUYU_PAYMENT_QR_CONCURRENCY", - 10, + 15, ) PAYMENT_QR_TASK_TYPES = frozenset( diff --git a/web/backend/services/douyu_service.py b/web/backend/services/douyu_service.py index 9eca097..c8f047c 100644 --- a/web/backend/services/douyu_service.py +++ b/web/backend/services/douyu_service.py @@ -167,7 +167,7 @@ def _env_positive_int(name: str, default: int) -> int: return value if value > 0 else default -DOUYU_MAX_ACTIVE_TASKS = _env_positive_int("DOUYU_MAX_ACTIVE_TASKS", 250) +DOUYU_MAX_ACTIVE_TASKS = _env_positive_int("DOUYU_MAX_ACTIVE_TASKS", 500) class DouyuActivePaymentError(ValueError): @@ -412,7 +412,7 @@ def create_douyu_planned_tasks( created_by: int, payload: dict | None = None, platform_task_id: int | None = None, - concurrency: int = 3, + concurrency: int = 5, enqueue_execution: bool = True, recharge_channel: str = "", recharge_amount: int | None = None, @@ -545,7 +545,7 @@ def create_douyu_planned_tasks( payload={ "task_type": task_type, "payload": payload, - "concurrency": max(1, min(int(concurrency), 10)), + "concurrency": max(1, min(int(concurrency), 15)), }, created_by=int(created_by), priority=40, diff --git a/web/backend/services/execution_worker.py b/web/backend/services/execution_worker.py index 63d9df5..4e34026 100644 --- a/web/backend/services/execution_worker.py +++ b/web/backend/services/execution_worker.py @@ -32,7 +32,7 @@ from .execution_jobs import ( ) from .login_service import LoginBatchRunner -DEFAULT_EXECUTION_WORKERS = 2 +DEFAULT_EXECUTION_WORKERS = 6 DEFAULT_POLL_SECONDS = 1 @@ -72,7 +72,7 @@ def _lane_slot_limits() -> dict[str, int]: ) auth_limit = _env_positive_int( "EXECUTION_WORKER_AUTH_JOBS", - max(1, total - 1), + max(1, total - 2), ) fulfillment_limit = _env_positive_int( "EXECUTION_WORKER_FULFILLMENT_JOBS", @@ -87,9 +87,7 @@ def _lane_slot_limits() -> dict[str, int]: def _lane_claim_order() -> tuple[str, ...]: """领取顺序:履约优先,登录用剩余槽位。""" lanes = _lane_scopes() - return tuple( - sorted(lanes, key=lambda lane: 0 if lane == LANE_FULFILLMENT else 1) - ) + return tuple(sorted(lanes, key=lambda lane: 0 if lane == LANE_FULFILLMENT else 1)) class ExecutionJobWorker: @@ -173,9 +171,7 @@ class ExecutionJobWorker: # 履约优先:先把 fulfillment 的槽填满,登录只用剩下的。 # 登录批次等邮箱验证码时可能持槽 25 分钟,绝不能把履约饿死。 for lane in _lane_claim_order(): - lane_free = lane_limits.get(lane, 0) - self._inflight.get( - lane, 0 - ) + lane_free = lane_limits.get(lane, 0) - self._inflight.get(lane, 0) take = min(slots, lane_free) if take <= 0: continue @@ -272,8 +268,7 @@ class ExecutionJobWorker: runner = LoginBatchRunner( db=db, account_ids=[ - int(value) - for value in payload.get("account_ids", []) + int(value) for value in payload.get("account_ids", []) ], created_by=int(job.created_by), creator_permissions=get_user_permissions(user), @@ -285,7 +280,9 @@ class ExecutionJobWorker: concurrency=int(payload.get("concurrency", 3) or 3), api_strategy=str(payload.get("api_strategy", "wgapi") or "wgapi"), mode=str(payload.get("mode", "login") or "login"), - trigger_source=str(payload.get("trigger_source", "manual") or "manual"), + trigger_source=str( + payload.get("trigger_source", "manual") or "manual" + ), batch_id=job.batch_id, log_sink=log_sink, ) diff --git a/web/backend/services/task_runtime.py b/web/backend/services/task_runtime.py index f2fdeac..6af4fe7 100644 --- a/web/backend/services/task_runtime.py +++ b/web/backend/services/task_runtime.py @@ -52,22 +52,22 @@ class LaneConfig: _DEFAULT_WORKERS: dict[TaskLane, int] = { - TaskLane.INTERACTIVE_BINDING: 3, - TaskLane.BATCH_COORDINATOR: 2, - TaskLane.BINDING_POLL: 6, - TaskLane.LOGIN: 4, - TaskLane.ACCOUNT_CHECK: 4, - TaskLane.ACCOUNT_SYNC: 3, - TaskLane.AUTOMATION: 2, - TaskLane.OVERVIEW_QUERY: _env_int("DOUYU_MAX_ACTIVE_OVERVIEW_TASKS", 5), - TaskLane.QUERY_BATCH: 3, - TaskLane.COLLAB_RECOMMEND: 2, - TaskLane.PAYMENT_QR: 10, - TaskLane.PAYMENT_POLL: 3, - TaskLane.OPS_WRITE: 2, - TaskLane.HUYA_BATCH: 2, - TaskLane.HUYA_REGISTER: 2, - TaskLane.INTEGRATION: 2, + TaskLane.INTERACTIVE_BINDING: 6, + TaskLane.BATCH_COORDINATOR: 6, + TaskLane.BINDING_POLL: 12, + TaskLane.LOGIN: 8, + TaskLane.ACCOUNT_CHECK: 8, + TaskLane.ACCOUNT_SYNC: 6, + TaskLane.AUTOMATION: 3, + TaskLane.OVERVIEW_QUERY: _env_int("DOUYU_MAX_ACTIVE_OVERVIEW_TASKS", 10), + TaskLane.QUERY_BATCH: 10, + TaskLane.COLLAB_RECOMMEND: 4, + TaskLane.PAYMENT_QR: 12, + TaskLane.PAYMENT_POLL: 6, + TaskLane.OPS_WRITE: 6, + TaskLane.HUYA_BATCH: 5, + TaskLane.HUYA_REGISTER: 3, + TaskLane.INTEGRATION: 4, TaskLane.MAINTENANCE: 1, } diff --git a/web/frontend/src/pages/douyu-tasks/DouyuTasksPage.tsx b/web/frontend/src/pages/douyu-tasks/DouyuTasksPage.tsx index d22b9ce..93e2b89 100644 --- a/web/frontend/src/pages/douyu-tasks/DouyuTasksPage.tsx +++ b/web/frontend/src/pages/douyu-tasks/DouyuTasksPage.tsx @@ -224,7 +224,7 @@ export default function DouyuTasksPage({ const [loading, setLoading] = useState(false); const [runningBatchIds, setRunningBatchIds] = useState>(new Set()); const [configOpen, setConfigOpen] = useState(false); - const [concurrency, setConcurrency] = useState(3); + const [concurrency, setConcurrency] = useState(5); const [goldAmount, setGoldAmount] = useState(() => savedPositiveInteger(DOUYU_GOLD_AMOUNT_STORAGE_KEY)); // 历史兑换截图默认不展示;只有本页面本次实际发起过兑换的账号才显示。 const [exchangeImageAccountIds, setExchangeImageAccountIds] = useState>(() => new Set()); @@ -1076,10 +1076,10 @@ export default function DouyuTasksPage({ } // 支付码批次尽量一次全出码,队列只负责展示和等待到账,不让人工等前一个付完才生成下一个。 const batchConcurrency = DOUYU_PAYMENT_TASK_TYPE_SET.has(taskType) - ? Math.min(10, Math.max(concurrency, ids.length)) + ? Math.min(15, Math.max(concurrency, ids.length)) : taskType === 'query_account_overview' - ? Math.min(5, Math.max(concurrency, ids.length)) - : Math.min(5, concurrency); + ? Math.min(10, Math.max(concurrency, ids.length)) + : Math.min(10, concurrency); try { const result = await douyuApi.createTasks({ account_ids: ids,