summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/main.py b/main.py
index e1c6273..000a962 100644
--- a/main.py
+++ b/main.py
@@ -34,6 +34,16 @@ def get_urls(filename: str, limit: int | None = None) -> list[str]:
async def fetch(session: aiohttp.ClientSession, url: str, semaphore: asyncio.Semaphore) -> str:
+ """Fetch a URL under the given SESSION.
+
+ Use SEMAPHORE to limit the number of tasks that can make an HTTP
+ request at at time.
+
+ This function is the atomic task that executes concurrently with
+ its brethren to ping various websites.
+
+ """
+
try:
async with semaphore, session.get(url) as response:
print(".", end="", flush=True)