Skip to content

Process Execution Hangs with Large Command Output #84

@argonism

Description

@argonism

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions