fix(platform): 防止绑定任务压垮连接池和事件循环

This commit is contained in:
yml
2026-11-21 15:22:46 +08:00
parent d199e04d27
commit e1d979a296
13 changed files with 336 additions and 46 deletions
@@ -14,7 +14,7 @@ from ..database import WorkerSessionLocal
from ..models import DouyuTask
from .douyu_runner import DouyuBatchRunner
from .douyu_runner_core import DOUYU_PAYMENT_POLL_INTERVAL
from .task_runtime import TaskLane, submit
from .task_runtime import TaskLane, available_slots, try_submit
DEFAULT_INTERVAL_SECONDS = 1
DEFAULT_BATCH_SIZE = 30
@@ -182,10 +182,13 @@ def _release_callback(future: Future) -> None:
def run_payment_poll_dispatch_once(limit: int = DEFAULT_BATCH_SIZE) -> int:
claimed = _claim_due_payment_tasks(max(1, limit))
capacity = available_slots(TaskLane.PAYMENT_POLL)
if capacity <= 0:
return 0
claimed = _claim_due_payment_tasks(min(max(1, limit), capacity))
submitted = 0
for task_id in claimed:
future = submit(
future = try_submit(
TaskLane.PAYMENT_POLL,
poll_payment_task_once,
task_id,