get_async_type¶
-
privex.helpers.asyncx.
get_async_type
(obj) → str[source]¶ Detects if
obj
is an async object/function that needs awaited / called, whether it’s a synchronous callable, or whether it’s unknown (probably not async)>>> def sync_func(hello, world=1): return f"sync hello: {hello} {world}" >>> async def async_func(hello, world=1): return f"async hello: {hello} {world}" >>> get_async_type(async_func) 'coro func' >>> get_async_type(async_func(5)) 'coro' >>> get_async_type(sync_func) 'sync func' >>> get_async_type(sync_func(10)) 'unknown'
- Parameters
obj (Any) – Object to check for async type
- Return str async_type
Either
'coro func'
,'coro'
,'awaitable'
,'sync func'
or'unknown'