diff options
| author | Brandon C. Irizarry <brandon.irizarry@gmail.com> | 2026-04-16 17:42:49 -0400 |
|---|---|---|
| committer | Brandon C. Irizarry <brandon.irizarry@gmail.com> | 2026-04-16 17:42:49 -0400 |
| commit | 0c055dc725f0b8f1b697495884d65dc3ad16537d (patch) | |
| tree | bf9e35535ecb74350b680ccef6d7b414f0eb4744 | |
| parent | 528f5c261ec6dc2d0090930d4e79a8fef72d3cbd (diff) | |
feat: configure max_concurrency from the command line
| -rw-r--r-- | main.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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() |
