Skip to main content

run_endpoint_function

Executes a dependency or endpoint function by either awaiting it directly if it is a coroutine or running it in a threadpool if it is a synchronous function.

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

Executes the underlying endpoint function or dependency callable using the provided resolved values. This function handles the distinction between asynchronous and synchronous callables by either awaiting the coroutine directly or offloading the blocking call to a threadpool.

Parameters

NameTypeDescription
dependantDependantAn object containing the reference to the callable function to be executed.
valuesdict[str, Any]A dictionary of keyword arguments containing resolved dependencies and path/query parameters to pass to the function.
is_coroutineboolA flag indicating whether the callable is an 'async def' function that requires awaiting.

Returns

TypeDescription
AnyThe result returned by the endpoint function or dependency callable after execution.