]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-121605: Increase timeout in test_pyrepl.run_repl (#121606)
authorSam Gross <colesbury@gmail.com>
Sat, 13 Jul 2024 13:54:28 +0000 (09:54 -0400)
committerGitHub <noreply@github.com>
Sat, 13 Jul 2024 13:54:28 +0000 (15:54 +0200)
We also need to close the `slave_fd` earlier so that reading from
`master_fd` won't block forever when the subprocess finishes.

Lib/test/test_pyrepl/test_pyrepl.py

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