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.
This commit is contained in:
user
2026-02-17 19:02:36 +01:00
parent aac69f6a3e
commit ba60d087c0

View File

@@ -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)