Skip to content

execution

mlte/measurement/utility/execution.py

Utilities for execution of measurements.

concurrently(*callables)

Run an arbitrary number of functions concurrently.

Parameters:

Name Type Description Default
callables Callable[[], Any]

The callables to execute

()

Returns:

Type Description
List[Any]

The results of all callables, in the order in which they were passed to call

Source code in mlte/measurement/utility/execution.py
11
12
13
14
15
16
17
18
19
20
21
22
def concurrently(*callables: Callable[[], Any]) -> List[Any]:
    """
    Run an arbitrary number of functions concurrently.

    :param callables: The callables to execute

    :return: The results of all callables, in
    the order in which they were passed to call
    """
    with concurrent.futures.ThreadPoolExecutor() as executor:
        futures = [executor.submit(callable) for callable in callables]
        return [future.result() for future in futures]