瀏覽代碼

Merge pull request #1510 from Avaiga/feature/#1470-setup-spawn-method-for-subprocess-creation

#1470 setup spawn method for creating subprocesses
Toan Quach 10 月之前
父節點
當前提交
32e68a54cd
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      taipy/core/_orchestrator/_dispatcher/_standalone_job_dispatcher.py

+ 3 - 3
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,9 +34,8 @@ class _StandaloneJobDispatcher(_JobDispatcher):
         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,
-        )  # type: ignore
+            max_workers=max_workers, initializer=subproc_initializer, mp_context=mp.get_context("spawn")
+        )
         self._nb_available_workers = self._executor._max_workers  # type: ignore
 
     def _can_execute(self) -> bool: