langchain_core.runnables.config.run_in_executor¶

async langchain_core.runnables.config.run_in_executor(executor_or_config: ~typing.Optional[~typing.Union[~concurrent.futures._base.Executor, ~langchain_core.runnables.config.RunnableConfig]], 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 (Optional[Union[Executor, RunnableConfig]]) – 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¶