diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-06-12 19:58:29 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 19:58:29 (GMT) |
| commit | ff358616ddb5da18c79ceffabb55c3806a345383 (patch) | |
| tree | ca43f09493b8d069289fe6a70dc07d93465ad308 /Lib/test/test_pyrepl/test_pyrepl.py | |
| parent | f7237284b9c1768e6feb19abfad1ec54ac44ad87 (diff) | |
| download | cpython-ff358616ddb5da18c79ceffabb55c3806a345383.zip cpython-ff358616ddb5da18c79ceffabb55c3806a345383.tar.gz cpython-ff358616ddb5da18c79ceffabb55c3806a345383.tar.bz2 | |
[3.13] gh-118908: Protect the REPL subprocess with a timeout in tests (GH-120408) (#120430)
(cherry picked from commit 3453362183f083e37ea866a7ae1b34147ffaf81d)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
| -rw-r--r-- | Lib/test/test_pyrepl/test_pyrepl.py | 7 |
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 3167b84..41ba595 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 |
