Skip to content

gh-87512: Fix ignored timeout in subprocess.run() on Windows - #155409

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-87512-subprocess-timeout
Open

gh-87512: Fix ignored timeout in subprocess.run() on Windows#155409
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-87512-subprocess-timeout

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

The output is now read in chunks, using PeekNamedPipe() to get the available size, so the reading threads are always blocked in a cancelable read. The pending I/O is canceled before closing the pipes and after the timeout in run().

As a result, the output read before the timeout is now set on the TimeoutExpired exception, as on other platforms.

Added _winapi.OpenThread(), _winapi.CancelSynchronousIo() and _winapi.THREAD_TERMINATE, as suggested by @eryksun.

Note that _communicate() now decodes the output at the end, as the POSIX implementation does, because the reading threads no longer read via the TextIOWrapper.

The pipes can be inherited by processes which outlive the child process,
so reading them blocked until all of them exited, ignoring the timeout.

The output is now read in chunks and the pending I/O is canceled, so the
output read before the timeout is set on the TimeoutExpired exception, as
on other platforms.

Add _winapi.OpenThread(), _winapi.CancelSynchronousIo() and
_winapi.THREAD_TERMINATE.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33979004 | 📁 Comparing 4bdc075 against main (998b890)

  🔍 Preview build  

2 files changed
± library/audit_events.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant