From 890c000139f1faeb47e7c5e2ae542d5204b48a02 Mon Sep 17 00:00:00 2001 From: monosans Date: Thu, 25 Jan 2024 10:30:40 +0300 Subject: [PATCH] Don't shuffle proxies before checking --- proxy_scraper_checker/checker.py | 23 +++++++++++------------ proxy_scraper_checker/scraper.py | 25 +++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/proxy_scraper_checker/checker.py b/proxy_scraper_checker/checker.py index 00c5f5fa9..699271cc0 100644 --- a/proxy_scraper_checker/checker.py +++ b/proxy_scraper_checker/checker.py @@ -2,7 +2,6 @@ import asyncio import logging -from random import shuffle from typing import Mapping from aiohttp_socks import ProxyType @@ -53,15 +52,15 @@ async def check_all( for proto in sort.PROTOCOL_ORDER if proto in storage.enabled_protocols } - coroutines = [ - check_one( - progress=progress, - proxy=proxy, - settings=settings, - storage=storage, - task=tasks[proxy.protocol], + await asyncio.gather( + *( + check_one( + progress=progress, + proxy=proxy, + settings=settings, + storage=storage, + task=tasks[proxy.protocol], + ) + for proxy in storage ) - for proxy in storage - ] - shuffle(coroutines) - await asyncio.gather(*coroutines) + ) diff --git a/proxy_scraper_checker/scraper.py b/proxy_scraper_checker/scraper.py index 9f87a39cb..240d13337 100644 --- a/proxy_scraper_checker/scraper.py +++ b/proxy_scraper_checker/scraper.py @@ -94,17 +94,18 @@ async def scrape_all( for proto, sources in settings.sources.items() } timeout = ClientTimeout(total=settings.source_timeout) - coroutines = ( - scrape_one( - progress=progress, - proto=proto, - session=session, - source=source, - storage=storage, - task=tasks[proto], - timeout=timeout, + await asyncio.gather( + *( + scrape_one( + progress=progress, + proto=proto, + session=session, + source=source, + storage=storage, + task=tasks[proto], + timeout=timeout, + ) + for proto, sources in settings.sources.items() + for source in sources ) - for proto, sources in settings.sources.items() - for source in sources ) - await asyncio.gather(*coroutines)