From ba60d087c0e22b936d331ff0d69f5c1f8a7d5f28 Mon Sep 17 00:00:00 2001 From: user Date: Tue, 17 Feb 2026 19:02:36 +0100 Subject: [PATCH] fix: mark proxies alive incrementally during health tests Proxies that pass the TLS handshake are now immediately added to the alive list instead of waiting for the entire batch to complete. On cold start with large pools, this means proxies become available within seconds rather than waiting 30+ minutes. --- src/s5p/pool.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/s5p/pool.py b/src/s5p/pool.py index b50dba5..24487ae 100644 --- a/src/s5p/pool.py +++ b/src/s5p/pool.py @@ -306,9 +306,17 @@ class ProxyPool: async def _test(key: str, entry: ProxyEntry) -> None: async with sem: try: - results[key] = await self._test_proxy(key, entry) + ok = await self._test_proxy(key, entry) except Exception: - results[key] = False + ok = False + results[key] = ok + # mark passing proxies alive immediately so they're + # available before the full batch completes + if ok: + entry.alive = True + entry.fails = 0 + entry.last_ok = time.time() + self._alive_keys.append(key) tasks = [_test(k, e) for k, e in target] await asyncio.gather(*tasks)