优化(账号自动化): 履约保护登录配额与重登优先级
This commit is contained in:
@@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import threading
|
||||
from concurrent.futures import Future, ThreadPoolExecutor, wait
|
||||
from concurrent.futures import FIRST_COMPLETED, Future, ThreadPoolExecutor, wait
|
||||
from datetime import UTC, datetime
|
||||
from typing import Any
|
||||
|
||||
@@ -163,7 +163,7 @@ class ExecutionJobWorker:
|
||||
self._inflight[lane] = max(0, self._inflight.get(lane, 0) - 1)
|
||||
try:
|
||||
future.result()
|
||||
except Exception: # noqa: BLE001 - 结果已落库,这里只消费异常
|
||||
except Exception: # noqa: BLE001, S110 - 结果已落库,这里只消费异常
|
||||
pass
|
||||
executors = self._executors
|
||||
if not executors:
|
||||
@@ -190,13 +190,21 @@ class ExecutionJobWorker:
|
||||
jobs = []
|
||||
executor = executors.get(lane)
|
||||
for job in jobs:
|
||||
if executor is None:
|
||||
if executor is None or self._stop.is_set():
|
||||
break
|
||||
try:
|
||||
future = executor.submit(self._run_job, job.id)
|
||||
except RuntimeError:
|
||||
break
|
||||
self._inflight[lane] = self._inflight.get(lane, 0) + 1
|
||||
futures[executor.submit(self._run_job, job.id)] = lane
|
||||
futures[future] = lane
|
||||
slots -= len(jobs)
|
||||
if futures:
|
||||
wait(list(futures), timeout=poll_seconds)
|
||||
wait(
|
||||
list(futures),
|
||||
timeout=poll_seconds,
|
||||
return_when=FIRST_COMPLETED,
|
||||
)
|
||||
else:
|
||||
self._stop.wait(poll_seconds)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user