SlyAPI.asyncy#
Useful classes and functions for asynchronous programming.
Functions
|
Extract an async context manager's value without manually managing its lifetime. |
Classes
|
Async iterator which does not accumulate any results unless awaited. |
alias of |
- SlyAPI.asyncy.unmanage_async_context(context)[source]#
Extract an async context manager’s value without manually managing its lifetime. The context manager is entered until set() is called on the returned event.
thats it unmanages your async context manager
- Parameters:
context (AbstractAsyncContextManager[T]) –
- Return type:
tuple[_asyncio.Task[~T], asyncio.locks.Event]
- class SlyAPI.asyncy.AsyncLazy(gen)[source]#
Bases:
Generic
[T
]Async iterator which does not accumulate any results unless awaited. Awaiting instances will return a list of the results.
- Parameters:
gen (AsyncGenerator[T, None]) –
- gen: AsyncGenerator[T, None]#
- classmethod wrap(fn)[source]#
Convert an async generator async function to return an AsyncLazy instance.
- Parameters:
fn (Callable[[~T_Params], AsyncGenerator[T, None]]) –