Stop Windows hangs when last output is on stderr #72
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.
Terraform CLI runs sometimes only produce output on stderr, or writes its final output to stderr. Tests for variable validation conditions and pre/post conditions often elicit this behaviour. On Windows 10 and Python 3.9, this leads to a hang. Line 714 (in this PR) is a blocking operation that will never be satisfied given no further standard output will be observed.
This PR hacks around it when running on Windows by redirecting stderr to stdout. This truly is a hack, because later logic from line 724 onwards assumes
err
will contain stderr but will now always be empty. In practice, this seems to work on Windows OK.A better solution might be to do something like https://stackoverflow.com/a/4896288. This pushes my limited python-fu.