Skip to content

Commit e133c33

Browse files
authored
chore: Convert direct multiprocessing.set_start_method("forkserver") call to a pytest fixture. (#4377)
* chore: convert multiprocessing set_spawn to fixture in pytest * Switch to early return
1 parent 358ba45 commit e133c33

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
# Early diagnostic for failed imports
1818
import pybind11_tests
1919

20-
if os.name != "nt":
20+
21+
@pytest.fixture(scope="session", autouse=True)
22+
def always_forkserver_on_unix():
23+
if os.name == "nt":
24+
return
25+
2126
# Full background: https://github.com/pybind/pybind11/issues/4105#issuecomment-1301004592
2227
# In a nutshell: fork() after starting threads == flakiness in the form of deadlocks.
2328
# It is actually a well-known pitfall, unfortunately without guard rails.
@@ -27,6 +32,7 @@
2732
# running with defaults.
2833
multiprocessing.set_start_method("forkserver")
2934

35+
3036
_long_marker = re.compile(r"([0-9])L")
3137
_hexadecimal = re.compile(r"0x[0-9a-fA-F]+")
3238

0 commit comments

Comments
 (0)