aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_pyrepl/test_pyrepl.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2024-06-12 20:09:25 +0100
committerGitHub <noreply@github.com>2024-06-12 19:09:25 +0000
commit3453362183f083e37ea866a7ae1b34147ffaf81d (patch)
tree0e79694d033f91ee2ba2881e3411208292e27257 /Lib/test/test_pyrepl/test_pyrepl.py
parent4c6d4f5cb33e48519922d635894eef356faddba2 (diff)
downloadcpython-3453362183f083e37ea866a7ae1b34147ffaf81d.tar.gz
cpython-3453362183f083e37ea866a7ae1b34147ffaf81d.zip
gh-118908: Protect the REPL subprocess with a timeout in tests (#120408)
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
-rw-r--r--Lib/test/test_pyrepl/test_pyrepl.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py
index 3167b8473bf..41ba5959a1e 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