PyDocs

Nav

Networking and Interprocess Communication

Runner

asyncio

class · Added in 3.11 (source) not WASI
  • Runner(*, debug=None, loop_factory=None)
A context manager that controls event loop life cycle.

The context manager always creates a new event loop,
allows to run async functions inside it,
and properly finalizes the loop at the context manager exit.

If debug is True, the event loop will be run in debug mode.
If loop_factory is passed, it is used for new event loop creation.

asyncio.run(main(), debug=True)

is a shortcut for

with asyncio.Runner(debug=True) as runner:
    runner.run(main())

The run() method can be called multiple times within the runner's
context.

This can be useful for interactive console (e.g. IPython),
unittest runners, console tools, -- everywhere when async code
is called from existing sync framework and where the preferred single
asyncio.run() call doesn't work.
Members of Runner

c

close
Shutdown and close event loop.

g

get_loop
Return embedded event loop.

r

run
Run code in the embedded event loop.
0 Examples
No examples for asyncio/Runner.
See Also
No see-alsos for asyncio/Runner
0 Notes
No notes for Runner