From 828de9bb60f3825b0397f8b3dc15d70c416527c5 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 19 Jul 2026 18:34:32 +0300 Subject: [PATCH 1/2] gh-154167: Fix test suite hang when SIGINT is ignored Co-Authored-By: Claude Fable 5 --- Lib/test/libregrtest/setup.py | 8 ++++++++ .../Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 Misc/NEWS.d/next/Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst diff --git a/Lib/test/libregrtest/setup.py b/Lib/test/libregrtest/setup.py index b9b76a44e3b4e7..d62194acd9c29e 100644 --- a/Lib/test/libregrtest/setup.py +++ b/Lib/test/libregrtest/setup.py @@ -50,6 +50,14 @@ def setup_process() -> None: for signum in signals: faulthandler.register(signum, chain=True, file=stderr_fd) + # Restore the default SIGINT handler if there is no Python-level + # handler. Python inherits the SIG_IGN disposition when the test + # suite runs as a shell background job; then asyncio.Runner does not + # install its own handler and _thread.interrupt_main() is a no-op, + # which makes some tests in test_asyncio and test_threading hang. + if signal.getsignal(signal.SIGINT) in (signal.SIG_IGN, signal.SIG_DFL): + signal.signal(signal.SIGINT, signal.default_int_handler) + adjust_rlimit_nofile() support.record_original_stdout(sys.stdout) diff --git a/Misc/NEWS.d/next/Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst b/Misc/NEWS.d/next/Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst new file mode 100644 index 00000000000000..9cb6c506b86d91 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst @@ -0,0 +1,3 @@ +regrtest now restores the default SIGINT handler if it was inherited as +ignored, so the test suite no longer hangs when run as a shell background +job. From 9d6c3c65193bebf0aa4cdb3f25038d61fb15aea2 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 19 Jul 2026 18:37:25 +0300 Subject: [PATCH 2/2] Fix NEWS entry --- .../Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS.d/next/Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst b/Misc/NEWS.d/next/Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst index 9cb6c506b86d91..b2620f4a0bee54 100644 --- a/Misc/NEWS.d/next/Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst +++ b/Misc/NEWS.d/next/Tests/2026-07-19-20-15-00.gh-issue-154167.sigint.rst @@ -1,3 +1,3 @@ -regrtest now restores the default SIGINT handler if it was inherited as -ignored, so the test suite no longer hangs when run as a shell background -job. +The test runner (regrtest) now restores the default SIGINT handler if it +was inherited as ignored, so the test suite no longer hangs when run as +a shell background job.