Skip to content

Commit 3453362

Browse files
authored
pythongh-118908: Protect the REPL subprocess with a timeout in tests (python#120408)
1 parent 4c6d4f5 commit 3453362

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_pyrepl/test_pyrepl.py

+6-1
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)