From 9be0a56ddce51fdb87f7b9a9c87637de5266c010 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Thu, 2 Nov 2023 08:39:10 -0400 Subject: [PATCH] warn that fork should not be used for macos --- doc/modules/core.rst | 6 +++--- src/spikeinterface/core/job_tools.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/doc/modules/core.rst b/doc/modules/core.rst index 976a82a4a3..4c03950b1d 100644 --- a/doc/modules/core.rst +++ b/doc/modules/core.rst @@ -518,9 +518,9 @@ These are a set of keyword arguments which are common to all functions that supp A float like 0.5 means half of the availables core. * progress_bar: bool If True, a progress bar is printed -* mp_context: str or None - Context for multiprocessing. It can be None (default), "fork" or "spawn". - Note that "fork" is only available on UNIX systems (not Windows) +* mp_context: "fork" | "spawn" | None, default: None + "fork" or "spawn". If None, the context is taken by the recording.get_preferred_mp_context(). + "fork" is only safely available on LINUX systems. The default **job_kwargs** are :code:`n_jobs=1, chunk_duration="1s", progress_bar=True`. diff --git a/src/spikeinterface/core/job_tools.py b/src/spikeinterface/core/job_tools.py index a9df4f4626..3c6106084a 100644 --- a/src/spikeinterface/core/job_tools.py +++ b/src/spikeinterface/core/job_tools.py @@ -5,6 +5,7 @@ import numpy as np import platform import os +import warnings import joblib import sys @@ -30,9 +31,9 @@ Number of jobs to use. With -1 the number of jobs is the same as number of cores * progress_bar: bool If True, a progress bar is printed - * mp_context: str or None - Context for multiprocessing. It can be None (default), "fork" or "spawn". - Note that "fork" is only available on UNIX systems + * mp_context: "fork" | "spawn" | None, default: None + Context for multiprocessing. It can be None, "fork" or "spawn". + Note that "fork" is only safely available on LINUX systems """ @@ -287,9 +288,9 @@ class ChunkRecordingExecutor: Size of each chunk in number of samples. If "total_memory" or "chunk_memory" are used, it is ignored. chunk_duration : str or float or None Chunk duration in s if float or with units if str (e.g. "1s", "500ms") - mp_context : str or None, default: None + mp_context : "fork" | "spawn" | None, default: None "fork" or "spawn". If None, the context is taken by the recording.get_preferred_mp_context(). - "fork" is only available on UNIX systems. + "fork" is only safely available on LINUX systems. max_threads_per_process: int or None, default: None Limit the number of thread per process using threadpoolctl modules. This used only when n_jobs>1 @@ -332,6 +333,8 @@ def __init__( mp_context = recording.get_preferred_mp_context() if mp_context is not None and platform.system() == "Windows": assert mp_context != "fork", "'fork' mp_context not supported on Windows!" + elif mp_context is not None and platform.system() == "Darwin": + warnings.warn('As of Python 3.8 "fork" is no longer considered safe on MacOS') self.mp_context = mp_context