From 53e4816588d02e989354140fb25b018301584ee4 Mon Sep 17 00:00:00 2001 From: Toan Quach Date: Fri, 12 Jul 2024 15:51:56 +0700 Subject: [PATCH 1/2] setup spawn method for creating subprocesses --- .../_orchestrator/_dispatcher/_standalone_job_dispatcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/taipy/core/_orchestrator/_dispatcher/_standalone_job_dispatcher.py b/taipy/core/_orchestrator/_dispatcher/_standalone_job_dispatcher.py index 849f9b5901..d7bf8d390b 100644 --- a/taipy/core/_orchestrator/_dispatcher/_standalone_job_dispatcher.py +++ b/taipy/core/_orchestrator/_dispatcher/_standalone_job_dispatcher.py @@ -9,6 +9,7 @@ # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. +import multiprocessing as mp from concurrent.futures import Executor, ProcessPoolExecutor from functools import partial from threading import Lock @@ -33,8 +34,7 @@ def __init__(self, orchestrator: _AbstractOrchestrator, subproc_initializer: Opt super().__init__(orchestrator) max_workers = Config.job_config.max_nb_of_workers or self._DEFAULT_MAX_NB_OF_WORKERS self._executor: Executor = ProcessPoolExecutor( - max_workers=max_workers, - initializer=subproc_initializer, + max_workers=max_workers, initializer=subproc_initializer, mp_context=mp.get_context("spawn") ) # type: ignore self._nb_available_workers = self._executor._max_workers # type: ignore From 9d869131f24970a5e2724c183defd8d6b2fcf7d3 Mon Sep 17 00:00:00 2001 From: Toan Quach Date: Fri, 12 Jul 2024 16:17:09 +0700 Subject: [PATCH 2/2] remove type ignore --- .../_orchestrator/_dispatcher/_standalone_job_dispatcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taipy/core/_orchestrator/_dispatcher/_standalone_job_dispatcher.py b/taipy/core/_orchestrator/_dispatcher/_standalone_job_dispatcher.py index d7bf8d390b..c5143030f1 100644 --- a/taipy/core/_orchestrator/_dispatcher/_standalone_job_dispatcher.py +++ b/taipy/core/_orchestrator/_dispatcher/_standalone_job_dispatcher.py @@ -35,7 +35,7 @@ def __init__(self, orchestrator: _AbstractOrchestrator, subproc_initializer: Opt max_workers = Config.job_config.max_nb_of_workers or self._DEFAULT_MAX_NB_OF_WORKERS self._executor: Executor = ProcessPoolExecutor( max_workers=max_workers, initializer=subproc_initializer, mp_context=mp.get_context("spawn") - ) # type: ignore + ) self._nb_available_workers = self._executor._max_workers # type: ignore def _can_execute(self) -> bool: