Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-118908: Protect the REPL subprocess with a timeout in tests
  • Loading branch information
pablogsal committed Jun 12, 2024
commit 47e3511fd537696702a020c011f32792a507004a
8 changes: 7 additions & 1 deletion Lib/test/test_pyrepl/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -885,5 +886,10 @@ 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.terminate()
Comment thread
pablogsal marked this conversation as resolved.
Outdated
process.kill()
Comment thread
pablogsal marked this conversation as resolved.
Outdated
exit_code = process.returncode
return "\n".join(output), exit_code