-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Problem Description
When executing external commands that produce a large volume of output (both standard output and standard error), the process execution intermittently hangs and never completes. This issue can be reproduced when running tools like mypy if they generate a large number of errors.
Root Cause
The current implementation utilizes a mechanism (e.g., subprocess.poll()) for waiting for the sub-process to complete, but it does not simultaneously read and consume all the data from the child process's stdout and stderr pipes, which makes hang.
The Python documentation for subprocess.Popen.wait() explicitly warns about this potential deadlock when pipes are used:
This will deadlock when using stdout=PIPE or stderr=PIPE and the child process generates enough output to a pipe such that it blocks waiting for the OS pipe buffer to accept more data. Use Popen.communicate() when using pipes to avoid that.
https://docs.python.org/3.13/library/subprocess.html#subprocess.Popen.wait
Suggested Fix
This issue is addressed in the following Pull Request, which replaces the poll with subprocess.communicate() to safely drain the pipe buffers: #83