Bug report
When the test suite is started as a shell background job (e.g. nohup ./python -m test -j8 &), POSIX shells set SIGINT to SIG_IGN and Python does not install its default SIGINT handler. Then _thread.interrupt_main() is a no-op (PyErr_SetInterruptEx() does nothing when the handler is SIG_IGN or SIG_DFL) and asyncio.Runner does not install its own SIGINT handler, so tests relying on them in test_asyncio.test_runners and test_threading wait forever. In test_runners the event loop uses a mocked selector, so it busy-spins at 100% CPU while the Mock call history grows without bound (7 GiB in 20 minutes). There is no default test timeout, so the run never finishes.
Reproducer: sh -c 'trap "" INT; ./python -m test test.test_asyncio.test_runners'
Platform-independent (verified on Linux, FreeBSD, NetBSD). Note that GNU coreutils timeout masks the problem: it catches SIGINT itself, so a child it execs gets SIG_DFL restored.
Fix: restore the default SIGINT handler in regrtest's setup_process() when there is no Python-level handler.
Linked PRs
- gh-154167: Fix test suite hang when SIGINT is ignored #154168
- [3.15] gh-154167: Fix test suite hang when SIGINT is ignored (GH-154168) #154265
- [3.14] gh-154167: Fix test suite hang when SIGINT is ignored (GH-154168) #154266
- [3.13] gh-154167: Fix test suite hang when SIGINT is ignored (GH-154168) #154267