From: Pablo Galindo Salgado Date: Wed, 12 Jun 2024 19:09:25 +0000 (+0100) Subject: gh-118908: Protect the REPL subprocess with a timeout in tests (#120408) X-Git-Tag: v3.14.0a1~1513 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3453362183f083e37ea866a7ae1b34147ffaf81d;p=thirdparty%2FPython%2Fcpython.git gh-118908: Protect the REPL subprocess with a timeout in tests (#120408) --- diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index 3167b8473bfe..41ba5959a1ec 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -8,6 +8,7 @@ import sys from unittest import TestCase, skipUnless from unittest.mock import patch from test.support import force_not_colorized +from test.support import SHORT_TIMEOUT from .support import ( FakeConsole, @@ -885,5 +886,9 @@ class TestMain(TestCase): os.close(master_fd) os.close(slave_fd) - exit_code = process.wait() + try: + exit_code = process.wait(timeout=SHORT_TIMEOUT) + except subprocess.TimeoutExpired: + process.kill() + exit_code = process.returncode return "\n".join(output), exit_code