summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-04-16 17:42:49 -0400
committerBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-04-16 17:42:49 -0400
commit0c055dc725f0b8f1b697495884d65dc3ad16537d (patch)
treebf9e35535ecb74350b680ccef6d7b414f0eb4744
parent528f5c261ec6dc2d0090930d4e79a8fef72d3cbd (diff)
feat: configure max_concurrency from the command line
-rw-r--r--main.py10
1 files 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()