Async Python: asyncio Crash Course
Part 14 of the Python for Everyone track. Last updated: September 2026. asyncio lets one Python process juggle thousands of I/O-bound tasks — API calls, database queries, file reads — without threads. The mental model is small: async def , await , and an event loop that switches tasks while they wait. Your first coroutine import asyncio async def greet(): # async def makes a COROUTINE function await asyncio.sleep(1) # await: pause here, let others run return "hello" async def main(): result = await greet() # await runs the coroutine to completion print(result) asyncio.run(main()) # entry point: runs the event loop asyncio.run() is the standard entry point — it creates the event loop, runs your coroutine, and closes everything cleanly. Concurrency with gather import asyncio, time async def fetch(site): await asyncio.sleep(1) # pretend this is a network call return f"data from {site...