Execute a top-level coroutine and manage the event loop automatically.
Section: Getting Started
Run an async entrypoint
python
python
import asyncio
async def main():
print("hello")
await asyncio.sleep(1)
print("world")
asyncio.run(main())Explanation
Use `asyncio.run()` for most top-level programs. It creates the event loop, runs the coroutine, and closes the loop.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Getting Started
Use asyncio.Runner for multiple async calls
Reuse a managed loop for multiple top-level async calls.
Get the running loop and monotonic time
Use the loop clock for scheduling and deadlines.