From 0c055dc725f0b8f1b697495884d65dc3ad16537d Mon Sep 17 00:00:00 2001 From: "Brandon C. Irizarry" Date: Thu, 16 Apr 2026 17:42:49 -0400 Subject: feat: configure max_concurrency from the command line --- main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 000a962..cf647ff 100644 --- a/main.py +++ b/main.py @@ -57,7 +57,7 @@ async def fetch(session: aiohttp.ClientSession, url: str, semaphore: asyncio.Sem return "😴" -async def ping(urls: list[str], max_concurrency: int = 1) -> list[str]: +async def ping(urls: list[str], max_concurrency: int) -> list[str]: """Make a GET request to members of URLS. If MAX_CONCURRENCY is None, browse every site at once. @@ -81,13 +81,17 @@ async def ping(urls: list[str], max_concurrency: int = 1) -> list[str]: def main(): limit: int | None = None - if len(sys.argv) > 1: + if len(sys.argv) >= 2: limit = int(sys.argv[1]) urls = get_urls("majestic_million.csv", limit) + max_concurrency = len(urls) + + if len(sys.argv) == 3: + max_concurrency = int(sys.argv[2]) start_time = time.perf_counter() - results = asyncio.run(ping(urls)) + results = asyncio.run(ping(urls, max_concurrency)) print() print(results) end_time = time.perf_counter() -- cgit v1.2.3