mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-118908: Protect the REPL subprocess with a timeout in tests (#120408)
This commit is contained in:
parent
4c6d4f5cb3
commit
3453362183
1 changed files with 6 additions and 1 deletions
|
|
@ -8,6 +8,7 @@
|
|||
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 @@ def run_repl(self, repl_input: str | list[str], env: dict | None = None) -> tupl
|
|||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue