|
@@ -24,12 +24,19 @@ from ._task_function_wrapper import _TaskFunctionWrapper
|
|
|
class _StandaloneJobDispatcher(_JobDispatcher):
|
|
|
"""Manages job dispatching (instances of `Job^` class) in an asynchronous way using a ProcessPoolExecutor."""
|
|
|
|
|
|
- def __init__(self, orchestrator: Optional[_AbstractOrchestrator], subproc_initializer: Optional[Callable] = None):
|
|
|
+ def __init__(self, orchestrator: _AbstractOrchestrator, subproc_initializer: Optional[Callable] = None):
|
|
|
super().__init__(orchestrator)
|
|
|
max_workers = Config.job_config.max_nb_of_workers or 1
|
|
|
- self._executor: Executor = ProcessPoolExecutor(max_workers=max_workers, initializer=subproc_initializer) # type: ignore
|
|
|
+ self._executor: Executor = ProcessPoolExecutor(
|
|
|
+ max_workers=max_workers,
|
|
|
+ initializer=subproc_initializer
|
|
|
+ ) # type: ignore
|
|
|
self._nb_available_workers = self._executor._max_workers # type: ignore
|
|
|
|
|
|
+ def run(self):
|
|
|
+ with self._executor:
|
|
|
+ super().run()
|
|
|
+
|
|
|
def _dispatch(self, job: Job):
|
|
|
"""Dispatches the given `Job^` on an available worker for execution.
|
|
|
|