On this page
  1. asyncio.run
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

asyncio.run

Prev: asyncio.print_call_graph | Up: asyncio | Next: asyncio.run_coroutine_threadsafe
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.run
Tags: #public #python3 #stdlib #asyncio


Import

import asyncio
from asyncio import run

Signature & Overview

asyncio.run(main, *, debug=None, loop_factory=None)

Execute the coroutine and return the result.

Usage

import asyncio

async def main() -> int:
    await asyncio.sleep(0)
    return 42

assert asyncio.run(main()) == 42

Gotchas

REPL Inspect

from asyncio import run
help(run)

Linked from

Related notes