summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-04-16 17:36:54 -0400
committerBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-04-16 17:36:54 -0400
commit528f5c261ec6dc2d0090930d4e79a8fef72d3cbd (patch)
tree1c8f45dfdeb7698d3c0812b4630c7f23f3297067
parent28bb531bd6eec1a9139944fd5b5d1d05a08becd2 (diff)
docs: add docstring to 'fetch'
-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)