Skip to content

Commit

Permalink
chore: Convert direct multiprocessing.set_start_method("forkserver") …
Browse files Browse the repository at this point in the history
…call to a pytest fixture. (#4377)

* chore: convert multiprocessing set_spawn to fixture in pytest

* Switch to early return
  • Loading branch information
Skylion007 authored Dec 1, 2022
1 parent 358ba45 commit e133c33
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
# Early diagnostic for failed imports
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
# In a nutshell: fork() after starting threads == flakiness in the form of deadlocks.
# It is actually a well-known pitfall, unfortunately without guard rails.
Expand All @@ -27,6 +32,7 @@
# running with defaults.
multiprocessing.set_start_method("forkserver")


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

Expand Down

0 comments on commit e133c33

Please sign in to comment.