Skip to content

Commit

Permalink
Change always_forkserver_on_unix() to `use_multiprocessing_forkserv…
Browse files Browse the repository at this point in the history
…er_on_linux()` (#4577)
  • Loading branch information
Ralf W. Grosse-Kunstleve authored Mar 16, 2023
1 parent c4c15d4 commit cf7d2e6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import difflib
import gc
import multiprocessing
import os
import re
import sys
import textwrap
import traceback

Expand All @@ -25,17 +25,16 @@


@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
# In a nutshell: fork() after starting threads == flakiness in the form of deadlocks.
# 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")


Expand Down

0 comments on commit cf7d2e6

Please sign in to comment.