diff options
| -rw-r--r-- | main.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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) |
