Make sure to read all data from stdout and stderr#290
Merged
Conversation
Instead of stopping when the process terminate, continue reading until all channels are closed. Signed-off-by: Stefan Marr <git@stefan-marr.de>
The previous code lifelocked on the EOF markers, i.e., empty strings. Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
There was a problem hiding this comment.
Pull Request Overview
This pull request enhances the subprocess output reading in verbose mode by ensuring that output from both stdout and stderr is fully captured until their respective channels are closed or an EOF marker is encountered, while ensuring the process termination is awaited.
- Introduces EOF flags (stdout_eof and stderr_eof) for both stdout and stderr
- Updates the read loop to check for closed channels and wait for process termination when no further data is available
- Adjusts the select mechanism to read with a timeout
Comments suppressed due to low confidence (1)
rebench/subprocess_with_timeout.py:94
- [nitpick] Add inline comments to explain the purpose and usage of the stdout_eof and stderr_eof flags to enhance code clarity.
stdout_eof = False
| ret = select(reads, [], [], 0.1) | ||
| for file_no in ret[0]: | ||
| if file_no == proc.stdout.fileno(): | ||
| read = output_as_str(proc.stdout.readline()) |
There was a problem hiding this comment.
Consider refactoring the duplicated logic for handling stdout and stderr reads into a helper function to improve maintainability and reduce code repetition.
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Contributor
|
Sorry, missed this. I've done no extensive testing, but I can confirm that this fixes my issue as defined in #289, indeed. Thanks! |
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.
This PR changes how data is read from a benchmarking process when we run in verbose mode.
We need to make sure we read all data, thus:
Before returning, we need to wait for the process to terminate, so that we have the return code.
This fixes #289.
@OctaveLarose could you review this?
I debugged it and tried it out on yuria2.