diff --git a/src/executorlib/executor/single.py b/src/executorlib/executor/single.py index 2f75d0c0..96125698 100644 --- a/src/executorlib/executor/single.py +++ b/src/executorlib/executor/single.py @@ -1,3 +1,4 @@ +from time import sleep from typing import Callable, Optional, Union from executorlib.executor.base import BaseExecutor @@ -188,6 +189,7 @@ def __init__( log_obj_size=log_obj_size, ) ) + _executor_self_test(exe=self._task_scheduler) class TestClusterExecutor(BaseExecutor): @@ -446,3 +448,20 @@ def create_single_node_executor( executor_kwargs=resource_dict, spawner=MpiExecSpawner, ) + + +def _executor_self_test(exe): + f = exe.submit(sum, [1, 1]) + counter = 0 + while not f.done() and counter < 10: + sleep(0.1) + counter += 1 + if not f.done(): + exe.shutdown(wait=False, cancel_futures=False) + raise TimeoutError( + 'Plase try "hostname_localhost=True" in the initialization of the SingleNodeExecutor(hostname_localhost=True).' + ) + else: + exe._future_hash_dict = {} + exe._task_hash_dict = {} + return True