Update CommandImplementation to handle large stdout#1808
Closed
TylerDixon wants to merge 4 commits intomasterfrom
Closed
Update CommandImplementation to handle large stdout#1808TylerDixon wants to merge 4 commits intomasterfrom
TylerDixon wants to merge 4 commits intomasterfrom
Conversation
8d6c963 to
5dabbff
Compare
nasquasha
approved these changes
Jun 5, 2024
|
oop CI looking real mad |
kenyonj
added a commit
that referenced
this pull request
Jun 14, 2024
This also removes support for Ruby versions < 3 Brings in changes from #1808 co-authored-by: Tyler Dixon <tylerdixon@github.com>
Contributor
|
closing in favor of #1814 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Markup renderers which were using the
CommandImplementationto render the markup were hanging whenever large files were provided. So this PR:CommandImplementation#executemethod to handle largestdoutandstderrstreams from called subprocessesWhy?
Previously, the implementation using
popen3would hang in the case of large files. Taking a closer look I tried a few things to see what was going on:rest2htmlprogram, instead of writing the results of a large RST file tostdout, I processed the file, wrote it to a file, and just wrote a random short string (asdf) to thestdoutbuffer. This of course lead to the wrong return result, but, no hang!rest2htmlback to it's original state, I tried to read thestdoutbuffer withstdout.readlinesbefore thewait_thrvalue. This also lead to no hang.Based on these 2, we can see that the python and ruby sides were causing one another to hang:
wait_thr.value.success?before reading thestdoutbufferstdoutbuffer was full, and therefore wasn't exiting to return a status.The fix
capture3is a wrapper aroundpopen3which creates new threads to read instdoutandstderrwhile waiting for a status to be reported. This means that we don't end up hanging due to a full buffer. Thecapture3implementation can be seen in:https://github.com/ruby/ruby/blob/83f02d42e0a3c39661dc99c049ab9a70ff227d5b/lib/open3.rb#L648-L677