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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user