uvloop

uvloop is a fast, drop-in replacement for the default asyncio event loop, built on libuv.

On Unix (Linux and macOS), using uvloop can improve asyncio performance.

uvloop is not supported on Windows.

Installation

Install Genesis with the uvloop extra:

pip install genesis[uvloop]

Usage

When the extra is installed, the Genesis CLI uses uvloop automatically.

In your own entry point, pass new_event_loop as the loop factory. It returns a uvloop loop when uvloop is available and a default asyncio loop otherwise:

import asyncio

from genesis import new_event_loop

with asyncio.Runner(loop_factory=new_event_loop) as runner:
    runner.run(main())
use_uvloop() is deprecated. It sets a global event loop policy, and asyncio policies are deprecated since Python 3.14 and removed in 3.16.

See also