Skip to main content

run_endpoint_function

Executes a given dependant function, either directly if it's a coroutine or within a threadpool if it's a synchronous function, passing the provided values as arguments.

def run_endpoint_function(
dependant: Dependant,
values: dict[str, Any],
is_coroutine: bool
) - > Any

Executes a given function, either directly if it's a coroutine or within a thread pool otherwise, to handle an endpoint request. This function is used internally by get_request_handler to facilitate profiling.

Parameters

NameTypeDescription
dependantDependantAn object containing the function to be called. It must have a callable attribute named call.
valuesdict[str, Any]A dictionary of keyword arguments to be passed to the dependant.call function.
is_coroutineboolA boolean indicating whether the dependant.call function is a coroutine. If true, it will be awaited directly; otherwise, it will be run in a thread pool.

Returns

TypeDescription
AnyThe result of the executed function.