Commit e133c33d by Aaron Gokaslan Committed by GitHub

chore: Convert direct multiprocessing.set_start_method("forkserver") call to a…

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
parent 358ba459
...@@ -17,7 +17,12 @@ import pytest ...@@ -17,7 +17,12 @@ import pytest
# Early diagnostic for failed imports # Early diagnostic for failed imports
import pybind11_tests import pybind11_tests
if os.name != "nt":
@pytest.fixture(scope="session", autouse=True)
def always_forkserver_on_unix():
if os.name == "nt":
return
# Full background: https://github.com/pybind/pybind11/issues/4105#issuecomment-1301004592 # Full background: https://github.com/pybind/pybind11/issues/4105#issuecomment-1301004592
# In a nutshell: fork() after starting threads == flakiness in the form of deadlocks. # In a nutshell: fork() after starting threads == flakiness in the form of deadlocks.
# It is actually a well-known pitfall, unfortunately without guard rails. # It is actually a well-known pitfall, unfortunately without guard rails.
...@@ -27,6 +32,7 @@ if os.name != "nt": ...@@ -27,6 +32,7 @@ if os.name != "nt":
# running with defaults. # running with defaults.
multiprocessing.set_start_method("forkserver") multiprocessing.set_start_method("forkserver")
_long_marker = re.compile(r"([0-9])L") _long_marker = re.compile(r"([0-9])L")
_hexadecimal = re.compile(r"0x[0-9a-fA-F]+") _hexadecimal = re.compile(r"0x[0-9a-fA-F]+")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment