betty.asyncio module

Provide asynchronous programming utilities.

final class betty.asyncio.LazyReAwaitable

Bases: ReAwaitable, Generic

A value that can be awaited multiple times while always returning the exact same value.

The proxied awaitable will at most be awaited once.

This is thread-safe, which means you can safely use this between different threads.

__init__(factory: Callable[[], Awaitable[ValueT]], /)
class betty.asyncio.ReAwaitable

Bases: ABC, Generic

A value that can be awaited multiple times.

async betty.asyncio.resolve_await(value: ResolvableAwaitable) T

Return a value, but await it first if it is awaitable.