Skip to content

Commit 097774a

Browse files
committed
pythongh-90872: Fix subprocess.Popen._wait() for negative timeout
On Windows, subprocess.Popen.wait() no longer calls WaitForSingleObject() with a negative timeout: pass 0 ms if the timeout is negative.
1 parent a3cf0fa commit 097774a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Lib/subprocess.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,8 @@ def _wait(self, timeout):
15861586
"""Internal implementation of wait() on Windows."""
15871587
if timeout is None:
15881588
timeout_millis = _winapi.INFINITE
1589+
elif timeout <= 0:
1590+
timeout_millis = 0
15891591
else:
15901592
timeout_millis = int(timeout * 1000)
15911593
if self.returncode is None:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
On Windows, :meth:`subprocess.Popen.wait` no longer calls
2+
``WaitForSingleObject()`` with a negative timeout: pass ``0`` ms if the
3+
timeout is negative. Patch by Victor Stinner.

0 commit comments

Comments
 (0)