From 4fb185512f64b31acbde38be7ff6130128f7a007 Mon Sep 17 00:00:00 2001 From: Mark Reitblatt Date: Wed, 17 Jun 2026 12:48:47 -0700 Subject: [PATCH] Fix docker-compose hang in CI (#370) Co-authored-by: Claude Sonnet 4.6 --- osprey_worker/conftest.py | 25 +++++++++++++++++++++++++ run-tests.sh | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/osprey_worker/conftest.py b/osprey_worker/conftest.py index c651b8c..e9f0d59 100644 --- a/osprey_worker/conftest.py +++ b/osprey_worker/conftest.py @@ -9,6 +9,9 @@ or from within osprey_worker/ subpaths. from typing import TYPE_CHECKING +import pytest +from gevent import monkey + if TYPE_CHECKING: from _pytest.config import Config from _pytest.config.argparsing import Parser @@ -55,3 +58,25 @@ def pytest_configure(config: 'Config') -> None: 'vary_output_by_py_version(): instructs the `check_output` feature to record a separate file for ' 'different python major/minor versions', ) + + +@pytest.hookimpl(trylast=True) +def pytest_sessionfinish(session: object, exitstatus: int) -> None: + """Force-exit the gevent-monkey-patched test process once the run is done. + + The test runner launches pytest under gevent monkey-patching + (``python -m gevent.monkey --module pytest``). After the suite finishes, + the process can stall inside gevent's interpreter finalization and never + exit, so the integration-tests CI job hangs until its 30-minute timeout. + Exit immediately here (trylast, so this runs after the junit/terminal + hooks) to skip that teardown. Guarded on gevent being active so a plain + ``pytest`` run finalizes normally. + """ + import os + import sys + + if not monkey.is_module_patched('socket'): + return + sys.stdout.flush() + sys.stderr.flush() + os._exit(exitstatus) diff --git a/run-tests.sh b/run-tests.sh index 4415a3a..53c037c 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker compose -f docker-compose.yaml -f docker-compose.test.yaml --profile test run --rm --remove-orphans test_runner run-tests "${@}" +docker compose -f docker-compose.yaml -f docker-compose.test.yaml --profile test run --rm -T test_runner run-tests "${@}" -- 2.51.2