https://github.com/python/cpython/commit/8cfe1ab887f71a103bd98a7f3862a914e52debcd
commit: 8cfe1ab887f71a103bd98a7f3862a914e52debcd
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: gpshead <[email protected]>
date: 2025-12-28T17:20:40Z
summary:

[3.13] gh-142195: Fixed Popen.communicate indefinite loops (GH-143203) (#143256)

gh-142195: Fixed Popen.communicate indefinite loops (GH-143203)

Changed condition to evaluate if timeout is less than or equals to 0. This is 
needed for simulated time environments such as Shadow where the time will match 
exactly on the boundary.

---------
(cherry picked from commit fa9a4254e81c0abcc3345021c45aaf5f788f9ea9)

Co-authored-by: Prithviraj Chaudhuri <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>

files:
A Misc/NEWS.d/next/Library/2025-12-27-00-14-56.gh-issue-142195.UgBEo5.rst
M Lib/subprocess.py

diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 885f0092b53113..3a8c7434d37b1a 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -2143,7 +2143,7 @@ def _communicate(self, input, endtime, orig_timeout):
 
                 while selector.get_map():
                     timeout = self._remaining_time(endtime)
-                    if timeout is not None and timeout < 0:
+                    if timeout is not None and timeout <= 0:
                         self._check_timeout(endtime, orig_timeout,
                                             stdout, stderr,
                                             skip_check_and_raise=True)
diff --git 
a/Misc/NEWS.d/next/Library/2025-12-27-00-14-56.gh-issue-142195.UgBEo5.rst 
b/Misc/NEWS.d/next/Library/2025-12-27-00-14-56.gh-issue-142195.UgBEo5.rst
new file mode 100644
index 00000000000000..b2b1ffe7225bd7
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-12-27-00-14-56.gh-issue-142195.UgBEo5.rst
@@ -0,0 +1 @@
+Updated timeout evaluation logic in :mod:`subprocess` to be compatible with 
deterministic environments like Shadow where time moves exactly as requested.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to