Пример #1
0
async def maybe_coroutine(f: MaybeAwaitableFunc[P, T], *args: P.args,
                          **kwargs: P.kwargs) -> T:
    value = f(*args, **kwargs)
    if _isawaitable(value):
        return await value
    else:
        return value  # type: ignore
Пример #2
0
async def maybe_coroutine(f, *args, **kwargs):
    value = f(*args, **kwargs)
    if _isawaitable(value):
        return await value
    else:
        return value
Пример #3
0
async def maybe_await(x):
    if _isawaitable(x):
        return await x
    else:
        return x
Пример #4
0
def create_task(loop, f, *args, **kwargs) -> None:
    value = f(*args, **kwargs)
    if _isawaitable(value):
        loop.create_task(value)
Пример #5
0
async def maybe_coroutine(f, *args, **kwargs):
    value = f(*args, **kwargs)
    if _isawaitable(value):
        return await value
    else:
        return value