]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-142195: Fixed Popen.communicate indefinite loops (GH-143203)
authorPrithviraj Chaudhuri <p.chaudhuri1993@gmail.com>
Sun, 28 Dec 2025 16:57:44 +0000 (11:57 -0500)
committerGitHub <noreply@github.com>
Sun, 28 Dec 2025 16:57:44 +0000 (16:57 +0000)
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.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Lib/subprocess.py
Misc/NEWS.d/next/Library/2025-12-27-00-14-56.gh-issue-142195.UgBEo5.rst [new file with mode: 0644]

index 17333d8c02255deb9d6e423e8e545437d511be0d..3cebd7883fcf29be800bd56137e91950a70e789e 100644 (file)
@@ -2140,7 +2140,7 @@ class Popen:
 
                 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 (file)
index 0000000..b2b1ffe
--- /dev/null
@@ -0,0 +1 @@
+Updated timeout evaluation logic in :mod:`subprocess` to be compatible with deterministic environments like Shadow where time moves exactly as requested.