Concurrency and Process Modules
asyncio
Cooperative concurrency with coroutines, tasks and an event loop. Awaiting a coroutine can suspend execution while other tasks progress; blocking synchronous work can stall the loop. asyncio.run manages a top-level event loop and cannot run inside another running loop in the same thread.
Formal Syntax & Structure
python syntaxpython
import asyncioReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
import asyncio
async def square(n): await asyncio.sleep(0) return n*n
async def main(): print(await asyncio.gather(square(2), square(3)))
asyncio.run(main())