From 8fa599392313b80392ba297e1178fe99ab98da2b Mon Sep 17 00:00:00 2001 From: Christopher Milan Date: Tue, 21 Jul 2026 17:42:58 -0400 Subject: [PATCH] replace pytest-timeout with SIGABRT hook (#17122) --- conftest.py | 10 ++++++++++ pyproject.toml | 3 --- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 conftest.py diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000000..8c84ede27f --- /dev/null +++ b/conftest.py @@ -0,0 +1,10 @@ +import os, pytest, signal, threading + +@pytest.hookimpl(wrapper=True) +def pytest_runtest_call(item): + t = threading.Timer(int(os.getenv("TEST_TIMEOUT", 300)), os.kill, args=(os.getpid(), signal.SIGABRT)) + t.start() + try: yield + finally: + t.cancel() + t.join() diff --git a/pyproject.toml b/pyproject.toml index aab388d81d..5a7533ea8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,6 @@ testing_minimal = [ "torch==2.9.1", "pytest", "pytest-xdist", - "pytest-timeout", "pytest-split", "hypothesis>=6.148.9", "z3-solver<4.15.4", # 4.15.4 has a segfault when creating many z3.Context() @@ -160,8 +159,6 @@ norecursedirs = [ ".hypothesis", ".git", ] -timeout = 300 -timeout_func_only = true testpaths = ["test"] filterwarnings = [ # Ignore SWIG warnings from importlib