bartender.async_utils#

Functions#

async_wrap(→ Callable[Ellipsis, Awaitable[Any]])

Wraps a synchronous function to run asynchronously.

Module Contents#

bartender.async_utils.async_wrap(func: Callable[Ellipsis, Any]) Callable[Ellipsis, Awaitable[Any]]#

Wraps a synchronous function to run asynchronously.

Example

>>> def sum(a, b):
...     return a + b
>>> async_sum = async_wrap(sum)
>>> result = await async_sum(1, 2)
3
Parameters:

func (Callable[Ellipsis, Any]) – The synchronous function to wrap.

Returns:

An asynchronous function that wraps the synchronous function.

Return type:

Callable[Ellipsis, Awaitable[Any]]