summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pyrepl/test_pyrepl.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-07-13 16:07:12 (GMT)
committerGitHub <noreply@github.com>2024-07-13 16:07:12 (GMT)
commit14c5bffcc552fec1276f078dd8d20688d4e71c78 (patch)
treed5f4b9b43276ab6efaabe7970b1e78dae0a46ebd /Lib/test/test_pyrepl/test_pyrepl.py
parent4af9c05e788debe0c6194db68b359b6b8200136a (diff)
downloadcpython-14c5bffcc552fec1276f078dd8d20688d4e71c78.zip
cpython-14c5bffcc552fec1276f078dd8d20688d4e71c78.tar.gz
cpython-14c5bffcc552fec1276f078dd8d20688d4e71c78.tar.bz2
[3.13] gh-121605: Increase timeout in test_pyrepl.run_repl (GH-121606) (#121702)
We also need to close the `slave_fd` earlier so that reading from `master_fd` won't block forever when the subprocess finishes. (cherry picked from commit abc3aeebdbae560476f2f8c0312e9a4bf0dbfd33) Co-authored-by: Sam Gross <colesbury@gmail.com>
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
-rw-r--r--Lib/test/test_pyrepl/test_pyrepl.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py
index 4320610..8fff372 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -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: