β All terms Β· Async & concurrency
asyncio.gather
Run multiple coroutines concurrently and wait for all of them. The bread-and-butter of fan-out.
results = await asyncio.gather(f(), g())
Learn this interactively:
Open lesson sr-25 β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β¦Event loopScheduler that drives async code β runs ready coroutines, parks blocked ones. `aβ¦GILGlobal Interpreter Lock β CPython's mutex that lets only one thread run Python bβ¦