From a6c8d2a4a7142b9525ae5cea3c2e160ad956e158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9F=C4=B1l=20Ulu=C5=9Fahin?= Date: Mon, 16 Nov 2026 15:42:46 +0000 Subject: [PATCH 1/3] Add a CI test job timeout --- .github/workflows/test-suite.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 77118c42e3..45eb78b9de 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -11,6 +11,7 @@ jobs: tests: name: "Python ${{ matrix.python-version }}" runs-on: "ubuntu-latest" + timeout-minutes: 15 strategy: matrix: From ef8a91beeab1c974c6867e38c4b1ef3466bf6e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9F=C4=B1l=20Ulu=C5=9Fahin?= Date: Mon, 16 Nov 2026 15:42:49 +0000 Subject: [PATCH 2/3] Show stack traces when tests stall --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index f2c19ab095..5d0225e935 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -116,6 +116,7 @@ check_untyped_defs = true [tool.pytest.ini_options] addopts = "-rxXs" +faulthandler_timeout = 60 filterwarnings = [ "error", # Until https://github.com/encode/httpcore/pull/1119 fixes https://github.com/encode/httpx/issues/3597. From 8fda64fbd023ab60b1b7d208c0d833023243b312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9F=C4=B1l=20Ulu=C5=9Fahin?= Date: Mon, 16 Nov 2026 15:42:51 +0000 Subject: [PATCH 3/3] Add timeouts to test server startup and shutdown --- tests/conftest.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 858bca1397..8df31016d9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -269,15 +269,28 @@ async def watch_restarts(self) -> None: # pragma: no cover def serve_in_thread(server: TestServer) -> typing.Iterator[TestServer]: - thread = threading.Thread(target=server.run) + thread = threading.Thread(target=server.run, daemon=True) + startup_deadline = time.monotonic() + 10 thread.start() try: while not server.started: + if not thread.is_alive(): + raise RuntimeError( # pragma: no cover + "Uvicorn test server exited before startup." + ) + if time.monotonic() > startup_deadline: + raise TimeoutError( # pragma: no cover + "Uvicorn test server did not start within 10 seconds." + ) time.sleep(1e-3) yield server finally: server.should_exit = True - thread.join() + thread.join(timeout=5) + if thread.is_alive(): + raise TimeoutError( # pragma: no cover + "Uvicorn test server did not stop within 5 seconds." + ) @pytest.fixture(scope="session")