β All terms Β· Async & concurrency
Event loop
Scheduler that drives async code β runs ready coroutines, parks blocked ones. `asyncio.run(main())` starts one.
Learn this interactively:
Open lesson sr-23 βRelated β Async & concurrency
async defDeclares a coroutine. Can be awaited; runs cooperatively on an event loop.awaitPauses a coroutine until another coroutine/Future finishes. Only legal inside `aβ¦GILGlobal Interpreter Lock β CPython's mutex that lets only one thread run Python bβ¦asyncio.gatherRun multiple coroutines concurrently and wait for all of them. The bread-and-butβ¦asyncio.TaskGroupStructured concurrency primitive (Python 3.11+). `async with TaskGroup()` ensureβ¦asyncio.wait_forCap any awaitable with a timeout: `await asyncio.wait_for(coro, timeout=5)`. Raiβ¦