Skip to content

Commit cf7d2e6

Browse files
authored
Change always_forkserver_on_unix() to use_multiprocessing_forkserver_on_linux() (#4577)
1 parent c4c15d4 commit cf7d2e6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tests/conftest.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import difflib
99
import gc
1010
import multiprocessing
11-
import os
1211
import re
12+
import sys
1313
import textwrap
1414
import traceback
1515

@@ -25,17 +25,16 @@
2525

2626

2727
@pytest.fixture(scope="session", autouse=True)
28-
def always_forkserver_on_unix():
29-
if os.name == "nt":
28+
def use_multiprocessing_forkserver_on_linux():
29+
if sys.platform != "linux":
30+
# The default on Windows and macOS is "spawn": If it's not broken, don't fix it.
3031
return
3132

3233
# Full background: https://github.com/pybind/pybind11/issues/4105#issuecomment-1301004592
3334
# In a nutshell: fork() after starting threads == flakiness in the form of deadlocks.
3435
# It is actually a well-known pitfall, unfortunately without guard rails.
3536
# "forkserver" is more performant than "spawn" (~9s vs ~13s for tests/test_gil_scoped.py,
3637
# visit the issuecomment link above for details).
37-
# Windows does not have fork() and the associated pitfall, therefore it is best left
38-
# running with defaults.
3938
multiprocessing.set_start_method("forkserver")
4039

4140

0 commit comments

Comments
 (0)