Practical usage of asyncio
summary
Explains practical asyncio usage: async/await coroutines, creating tasks with loop.create_task and waiting with asyncio.wait/run_until_complete, and why asyncio.sleep vs time.sleep matters (time.sleep blocks, asyncio raises await errors). Builds an aiohttp web scraper that counts occurrences of "the" across blogs, shows results arrive out of order and demonstrates per-task error handling for a mangled URL. Shows offloading blocking logging via run_in_executor to keep the event loop responsive and simplify debugging in a single process.
AI-written summary · about
chapters (9)
- 0:00Introduction to asyncio
- 2:04Traditional concurrency methods
- 4:13Event loop fundamentals
- 6:00Writing coroutines
- 9:58Non-blocking sleep demo
- 12:48Web scraping with aiohttp
- 17:47Handling async results
- 19:33Async logging solution
- 21:58Q&A and closing
related talks
30m"Asyncio by Example"
25mThe hitchhiker's guide to asyncio
32mAdvanced asyncio: Solving Real-World Production Problems
32mEnhancing AsyncIO for Complex Applications
24mA Crash Course in Python 3's asyncio
40mAdvanced asyncio: Solving Real-world Production Problems
31mA Really Gentle Introduction to Asyncio
59mGet to grips with asyncio in Python 3
