8000 [3.13] gh-118908: Protect the REPL subprocess with a timeout in tests… · python/cpython@ff35861 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit ff35861

Browse files
[3.13] gh-118908: Protect the REPL subprocess with a timeout in tests (GH-120408) (#120430)
(cherry picked from commit 3453362) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
1 parent f723728 commit ff35861

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_pyrepl/test_pyrepl.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from unittest import TestCase, skipUnless
99
from unittest.mock import patch
1010
from test.support import force_not_colorized
11+
from test.support import SHORT_TIMEOUT
1112

1213
from .support import (
1314
FakeConsole,
@@ -885,5 +886,9 @@ def run_repl(self, repl_input: str | list[str], env: dict | None = None) -> tupl
885886

886887
os.close(master_fd)
887888
os.close(slave_fd)
888-
exit_code = process.wait()
889+
try:
890+
exit_code = process.wait(timeout=SHORT_TIMEOUT)
891+
except subprocess.TimeoutExpired:
892+
process.kill()
893+
exit_code = process.returncode
889894
return "\n".join(output), exit_code

0 commit comments

Comments
 (0)
0