run_in_executor#

async langchain_core.runnables.config.run_in_executor(executor_or_config: ~concurrent.futures._base.Executor | ~langchain_core.runnables.config.RunnableConfig | None, func: ~typing.Callable[[~P], ~langchain_core.runnables.config.T], *args: ~typing.~P, **kwargs: ~typing.~P) T[source]#

Run a function in an executor.

Parameters:
  • executor_or_config (Executor | RunnableConfig | None) – The executor or config to run in.

  • func (Callable[P, Output]) – The function.

  • *args (Any) – The positional arguments to the function.

  • **kwargs (Any) – The keyword arguments to the function.

Returns:

The output of the function.

Return type:

Output

Raises:

RuntimeError – If the function raises a StopIteration.

Examples using run_in_executor