nemo_microservices._utils._sync#
Module Contents#
Functions#
Data#
API#
- nemo_microservices._utils._sync.T_ParamSpec#
‘ParamSpec(…)’
- nemo_microservices._utils._sync.T_Retval#
‘TypeVar(…)’
- nemo_microservices._utils._sync.asyncify(
- function: Callable[nemo_microservices._utils._sync.T_ParamSpec, nemo_microservices._utils._sync.T_Retval],
Take a blocking function and create an async one that receives the same positional and keyword arguments.
Usage:
def blocking_func(arg1, arg2, kwarg1=None): # blocking code return result result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1)
Arguments
function: a blocking regular callable (e.g. a function)Return
An async function that takes the same positional and keyword arguments as the original one, that when called runs the same original function in a thread worker and returns the result.
- async nemo_microservices._utils._sync.to_thread(
- func: Callable[nemo_microservices._utils._sync.T_ParamSpec, nemo_microservices._utils._sync.T_Retval],
- /,
- *args: nemo_microservices._utils._sync.T_ParamSpec,
- **kwargs: nemo_microservices._utils._sync.T_ParamSpec,