gh-121605: Increase timeout in test_pyrepl.run_repl (#121606)

We also need to close the `slave_fd` earlier so that reading from
`master_fd` won't block forever when the subprocess finishes.
This commit is contained in:
Sam Gross 2024-07-13 09:54:28 -04:00 committed by GitHub
parent 0a26aa5007
commit abc3aeebdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 5 deletions

View File

@ -982,19 +982,22 @@ class TestMain(TestCase):
close_fds=True, close_fds=True,
env=env if env else os.environ, env=env if env else os.environ,
) )
os.close(slave_fd)
if isinstance(repl_input, list): if isinstance(repl_input, list):
repl_input = "\n".join(repl_input) + "\n" repl_input = "\n".join(repl_input) + "\n"
os.write(master_fd, repl_input.encode("utf-8")) os.write(master_fd, repl_input.encode("utf-8"))
output = [] output = []
while select.select([master_fd], [], [], 0.5)[0]: while select.select([master_fd], [], [], SHORT_TIMEOUT)[0]:
try:
data = os.read(master_fd, 1024).decode("utf-8") data = os.read(master_fd, 1024).decode("utf-8")
if not data: if not data:
break break
except OSError:
break
output.append(data) output.append(data)
os.close(master_fd) os.close(master_fd)
os.close(slave_fd)
try: try:
exit_code = process.wait(timeout=SHORT_TIMEOUT) exit_code = process.wait(timeout=SHORT_TIMEOUT)
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired: