Skip to content

Commit

Permalink
Added more cases for multiprocessing start methods, and try/except st…
Browse files Browse the repository at this point in the history
…atements depending on error/warning raised
  • Loading branch information
VChristiaens committed Jul 31, 2024
1 parent 2ed8e35 commit a2ce534
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vip_hci/config/utils_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from inspect import signature, Parameter
from functools import wraps
import multiprocessing
import warnings
from vip_hci import __version__

sep = "―" * 80
Expand Down Expand Up @@ -475,9 +476,16 @@ def pool_map(nproc, fkt, *args, **kwargs):
avail_methods = multiprocessing.get_all_start_methods()
if 'fork' in avail_methods:
# faster when available
multiprocessing.set_start_method("fork", force=True)
warnings.filterwarnings("error") # allows to catch warning as error
try:
multiprocessing.set_start_method("fork", force=True)
except (DeprecationWarning, OSError):
multiprocessing.set_start_method("spawn", force=True)
elif 'forkserver' in avail_methods:
multiprocessing.set_start_method("forkserver", force=True)
else:
multiprocessing.set_start_method("spawn", force=True)
warnings.resetwarnings() # reset warning behaviour to default
from multiprocessing import Pool

# deactivate multithreading
Expand Down

0 comments on commit a2ce534

Please sign in to comment.