From cf7d2e6f15be7622515a77466e84bd9414737680 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 16 Mar 2023 14:33:34 -0700 Subject: [PATCH] Change `always_forkserver_on_unix()` to `use_multiprocessing_forkserver_on_linux()` (#4577) --- tests/conftest.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b60d3c956..ad5b47b4b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,8 +8,8 @@ import contextlib import difflib import gc import multiprocessing -import os import re +import sys import textwrap import traceback @@ -25,8 +25,9 @@ except Exception: @pytest.fixture(scope="session", autouse=True) -def always_forkserver_on_unix(): - if os.name == "nt": +def use_multiprocessing_forkserver_on_linux(): + if sys.platform != "linux": + # The default on Windows and macOS is "spawn": If it's not broken, don't fix it. return # Full background: https://github.com/pybind/pybind11/issues/4105#issuecomment-1301004592 @@ -34,8 +35,6 @@ def always_forkserver_on_unix(): # It is actually a well-known pitfall, unfortunately without guard rails. # "forkserver" is more performant than "spawn" (~9s vs ~13s for tests/test_gil_scoped.py, # visit the issuecomment link above for details). - # Windows does not have fork() and the associated pitfall, therefore it is best left - # running with defaults. multiprocessing.set_start_method("forkserver")