enpi_api.l2.util.execution
1import concurrent.futures 2from collections.abc import Sequence 3from typing import TypeVar 4 5from enpi_api.l2.types.execution import Execution 6 7ExecutionType = TypeVar("ExecutionType") 8 9 10def wait(execution: Execution[ExecutionType]) -> ExecutionType: 11 """Wait for a single execution to complete. 12 13 You should generally use the `.wait()` on a returned execution instead. 14 15 Args: 16 execution (Execution[ExecutionType]): The execution to wait for. 17 18 Returns: 19 ExecutionType: The result of the execution. 20 """ 21 return execution.wait() 22 23 24def wait_all_parallel(executions: Sequence[Execution[ExecutionType]]) -> list[ExecutionType]: 25 """Wait for all executions to complete in parallel. 26 27 Args: 28 executions (Sequence[Execution[ExecutionType]]): The executions to wait for. 29 30 Returns: 31 list[ExecutionType]: The results of the executions. 32 """ 33 with concurrent.futures.ThreadPoolExecutor() as executor: 34 return list(executor.map(wait, executions))
11def wait(execution: Execution[ExecutionType]) -> ExecutionType: 12 """Wait for a single execution to complete. 13 14 You should generally use the `.wait()` on a returned execution instead. 15 16 Args: 17 execution (Execution[ExecutionType]): The execution to wait for. 18 19 Returns: 20 ExecutionType: The result of the execution. 21 """ 22 return execution.wait()
Wait for a single execution to complete.
You should generally use the .wait() on a returned execution instead.
Arguments:
- execution (Execution[ExecutionType]): The execution to wait for.
Returns:
ExecutionType: The result of the execution.
def
wait_all_parallel( executions: Sequence[enpi_api.l2.types.execution.Execution[TypeVar]]) -> list[~ExecutionType]:
25def wait_all_parallel(executions: Sequence[Execution[ExecutionType]]) -> list[ExecutionType]: 26 """Wait for all executions to complete in parallel. 27 28 Args: 29 executions (Sequence[Execution[ExecutionType]]): The executions to wait for. 30 31 Returns: 32 list[ExecutionType]: The results of the executions. 33 """ 34 with concurrent.futures.ThreadPoolExecutor() as executor: 35 return list(executor.map(wait, executions))
Wait for all executions to complete in parallel.
Arguments:
- executions (Sequence[Execution[ExecutionType]]): The executions to wait for.
Returns:
list[ExecutionType]: The results of the executions.