Skip to content

call_or_await

fast_depends.utils.run_async async #

run_async(
    func: Union[Callable[P, T], Callable[P, Awaitable[T]]],
    *args: P.args,
    **kwargs: P.kwargs
) -> T
Source code in fast_depends/utils.py
async def run_async(
    func: Union[
        Callable[P, T],
        Callable[P, Awaitable[T]],
    ],
    *args: P.args,
    **kwargs: P.kwargs,
) -> T:
    if is_coroutine_callable(func):
        return await cast(Callable[P, Awaitable[T]], func)(*args, **kwargs)
    else:
        return await run_in_threadpool(cast(Callable[P, T], func), *args, **kwargs)

Last update: 2023-11-13