programming#python#async#asyncio
Python Async: A Practical Guide
asyncio, event loops and when NOT to use async.
Python Async: A Practical Guide
Use asyncio when you're I/O bound — HTTP calls, DB queries, file I/O.
Don't reach for it for CPU-bound work; use multiprocessing or Rust extensions instead.
import asyncio, httpx
async def fetch(url):
async with httpx.AsyncClient() as c:
r = await c.get(url)
return r.text
async def main():
urls = [f"https://example.com/{i}" for i in range(50)]
results = await asyncio.gather(*(fetch(u) for u in urls))
print(len(results))
asyncio.run(main())
Keep reading
You may also like
programming
YAML Explained with Examples
YAML is everywhere in DevOps (Docker Compose, Kubernetes, GitHub Actions). Learn its 6 rules and you're done.
Read
programming
Python Data Structures: Lists, Dicts and Sets
The three collections you'll use every single day — with real examples.
Read
programming
Python for Absolute Beginners
The absolute essentials of Python — variables, if, loops and functions — in the clearest possible words, with runnable examples.
Read
Discussion (0)
No comments yet. Be the first to weigh in.