From 2ed8e350df746579fe90cea00d8f8be5f34ce8d0 Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Wed, 31 Jul 2024 19:28:39 +0200 Subject: [PATCH] Attempt to add multiprocessing support for Windows users --- vip_hci/config/utils_conf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vip_hci/config/utils_conf.py b/vip_hci/config/utils_conf.py index 1938ef14..c5d42fd8 100644 --- a/vip_hci/config/utils_conf.py +++ b/vip_hci/config/utils_conf.py @@ -471,7 +471,13 @@ def pool_map(nproc, fkt, *args, **kwargs): if not _generator: res = list(res) else: - multiprocessing.set_start_method("fork", force=True) + # Check available start methods and pick accordingly (machine-dependent) + avail_methods = multiprocessing.get_all_start_methods() + if 'fork' in avail_methods: + # faster when available + multiprocessing.set_start_method("fork", force=True) + else: + multiprocessing.set_start_method("spawn", force=True) from multiprocessing import Pool # deactivate multithreading