Skip to content

tests: skip some flaky gil tests on nogil #5699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions tests/test_gil_scoped.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
import env
from pybind11_tests import gil_scoped as m

skipif_not_free_threaded = pytest.mark.skipif(
not getattr(sys, "_is_gil_enabled", lambda: True)(),
reason="Flaky without the GIL",
)


class ExtendedVirtClass(m.VirtClass):
def virtual_func(self):
Expand Down Expand Up @@ -155,7 +160,7 @@ def _intentional_deadlock():
m.intentional_deadlock()


ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK = ALL_BASIC_TESTS + (_intentional_deadlock,)
ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK = (*ALL_BASIC_TESTS, _intentional_deadlock)


def _run_in_process(target, *args, **kwargs):
Expand Down Expand Up @@ -227,6 +232,7 @@ def test_run_in_process_one_thread(test_fn):
assert _run_in_process(_run_in_threads, test_fn, num_threads=1, parallel=False) == 0


@skipif_not_free_threaded
@pytest.mark.skipif(sys.platform.startswith("emscripten"), reason="Requires threads")
@pytest.mark.parametrize("test_fn", ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK)
@pytest.mark.skipif(
Expand Down Expand Up @@ -256,7 +262,13 @@ def test_run_in_process_multiple_threads_sequential(test_fn):


@pytest.mark.skipif(sys.platform.startswith("emscripten"), reason="Requires threads")
@pytest.mark.parametrize("test_fn", ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK)
@pytest.mark.parametrize(
"test_fn",
[
*ALL_BASIC_TESTS,
pytest.param(_intentional_deadlock, marks=skipif_not_free_threaded),
],
)
@pytest.mark.skipif(
"env.GRAALPY",
reason="GraalPy transiently complains about unfinished threads at process exit",
Expand Down
Loading