fix(worker): 优化连接池容量拆分、并发入队与事件写入
This commit is contained in:
@@ -238,8 +238,13 @@ class DouyuBatchRunner(
|
||||
self.db.commit()
|
||||
for task in tasks:
|
||||
self._push_task_event(task)
|
||||
task_ids = [int(task.id) for task in tasks]
|
||||
# 批次调度阶段后续只等待各任务子槽完成,不再使用外层会话;
|
||||
# 尽早释放连接,避免阻塞期间白占连接池。
|
||||
if getattr(self, "close_db", True):
|
||||
self.db.close()
|
||||
|
||||
total = len(tasks)
|
||||
total = len(task_ids)
|
||||
lane = douyu_lane_for_task(self.task_type)
|
||||
pending: dict = {}
|
||||
next_index = 0
|
||||
@@ -249,11 +254,11 @@ class DouyuBatchRunner(
|
||||
and next_index < total
|
||||
and len(pending) < self.concurrency
|
||||
):
|
||||
task = tasks[next_index]
|
||||
task_id = task_ids[next_index]
|
||||
future = submit(
|
||||
lane,
|
||||
self._execute_one,
|
||||
task.id,
|
||||
task_id,
|
||||
config,
|
||||
total,
|
||||
stopped=self._stop.is_set,
|
||||
|
||||
Reference in New Issue
Block a user