Round 5 fixes: workerpool resize shrink, validator lazy session close, plugin config error handling, 422 message detail, tests

This commit is contained in:
祀梦
2026-04-05 10:39:59 +08:00
parent d5fdfd65d9
commit 92c7fa19e2
5 changed files with 23 additions and 22 deletions

View File

@@ -84,19 +84,12 @@ class AsyncWorkerPool:
asyncio.create_task(self._worker_loop(i), name=f"{self.name}-worker-{i}")
)
elif new_worker_count < self.worker_count:
for _ in range(self.worker_count - new_worker_count):
await self._queue.put(None)
await asyncio.sleep(0)
still_running = []
for w in self._workers:
if w.done():
try:
await w
except asyncio.CancelledError:
pass
else:
still_running.append(w)
self._workers = still_running
excess_workers = self._workers[new_worker_count:]
self._workers = self._workers[:new_worker_count]
for w in excess_workers:
w.cancel()
if excess_workers:
await asyncio.gather(*excess_workers, return_exceptions=True)
self.worker_count = new_worker_count
async def _worker_loop(self, worker_id: int) -> None: