Skip to content

Commit 14e6371

Browse files
committed
Use multiprocessing.set_start_method("spawn") in conftest.py (very similar to pybind#4306, the only difference between the two PRs is the "spawn" vs "forkserver" argument).
1 parent 02bf5c9 commit 14e6371

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import contextlib
88
import difflib
99
import gc
10+
import multiprocessing
11+
import os
1012
import re
1113
import textwrap
1214

@@ -15,6 +17,9 @@
1517
# Early diagnostic for failed imports
1618
import pybind11_tests
1719

20+
if os.name != "nt":
21+
multiprocessing.set_start_method("spawn")
22+
1823
_long_marker = re.compile(r"([0-9])L")
1924
_hexadecimal = re.compile(r"0x[0-9a-fA-F]+")
2025

tests/test_gil_scoped.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ def _run_in_process(target, *args, **kwargs):
154154
test_fn = args[0]
155155
# Do not need to wait much, 10s should be more than enough.
156156
timeout = 0.1 if test_fn is _intentional_deadlock else 10
157-
mp_ctx = multiprocessing.get_context("spawn")
158-
process = mp_ctx.Process(target=target, args=args, kwargs=kwargs)
157+
process = multiprocessing.Process(target=target, args=args, kwargs=kwargs)
159158
process.daemon = True
160159
try:
161160
t_start = time.time()

0 commit comments

Comments
 (0)