agent0.utils.async_runner

General utility function for running synchronous functions asynchronously.

Attributes

R

Functions

async_runner(→ list[R])

Helper function that runs a list of passed in functions asynchronously.

Module Contents

agent0.utils.async_runner.R
async agent0.utils.async_runner.async_runner(funcs: Sequence[Callable[[], R]], return_exceptions: bool = False) list[R]

Helper function that runs a list of passed in functions asynchronously.

NOTE: use functools.partial() to pass in arguments to the functions.

WARNING: this assumes all functions passed in are thread safe, use at your own risk.

Parameters:
  • funcs (list[Callable[[], R]]) – List of functions to run asynchronously.

  • return_exceptions (bool) – If True, return exceptions from the functions. Otherwise, will throw exception if a thread fails.

Returns:

List of results.

Return type:

list[R]