Early-exit validation: stop once enough valid proxies found
- validate_proxies: target= param — once N valid found, remaining tasks skip the HTTP call and drain immediately (no wasted time) - _build_pool: target = max(min_pool_size, chain_length * 3) - Settings: min_pool_size (default 20), max_candidates default 400->200 - UI: Stop after N valid / Max candidates fields in Settings tab - README: updated settings table - 1 new test for early-exit with unreachable target Made-with: Cursor
This commit is contained in:
@@ -129,6 +129,20 @@ class TestValidator(unittest.TestCase):
|
||||
|
||||
self.assertEqual(asyncio.run(run()), [])
|
||||
|
||||
def test_validate_early_exit_target(self) -> None:
|
||||
"""Once target is reached remaining tasks should be skipped (all dead here → no early exit but no crash)."""
|
||||
async def run() -> list[str]:
|
||||
return await validate_proxies(
|
||||
["http://127.0.0.1:1"] * 10,
|
||||
"https://api.ipify.org?format=json",
|
||||
4,
|
||||
2.0,
|
||||
target=2, # target unreachable — should still return [] cleanly
|
||||
)
|
||||
|
||||
result = asyncio.run(run())
|
||||
self.assertEqual(result, [])
|
||||
|
||||
def test_get_direct_ip_network(self) -> None:
|
||||
async def run() -> str | None:
|
||||
return await get_direct_ip("https://api.ipify.org?format=json", 12.0)
|
||||
|
||||
Reference in New Issue
Block a user