Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we close stdout/stderr in Runner.run() #1123

Merged
merged 2 commits into from Sep 6, 2022

Conversation

Shrews
Copy link
Contributor

@Shrews Shrews commented Aug 24, 2022

If we treat warnings as errors with pytest (via -Werror or config file change), tests using subprocess code path will fail because we get a warning about an unclosed file on stderr.

Ultimately, the entire Runner.run() method probably needs reworked so that it is not so complex, and we can use better/safer coding methods, such as context managers on the open file handles. As it is now, using context managers on these file handles is a major pain since there is so much code between opening them and where we need to guarantee they are closed.

Provided test will fail without the code changes to close stdout/stderr.

@Shrews Shrews requested a review from a team as a code owner August 24, 2022 17:40
@github-actions github-actions bot added the needs_triage New item that needs to be triaged label Aug 24, 2022
@Shrews Shrews changed the title Make sure we close stderr Make sure we close stdout/stderr Aug 25, 2022
@Shrews Shrews changed the title Make sure we close stdout/stderr Make sure we close stdout/stderr in Runner.run() Aug 25, 2022
ansible_runner/runner.py Outdated Show resolved Hide resolved
@Akasurde Akasurde removed the needs_triage New item that needs to be triaged label Sep 6, 2022
Copy link
Contributor

@eqrx eqrx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks for doing this:)

@Shrews Shrews merged commit 2eab201 into ansible:devel Sep 6, 2022
@Shrews Shrews deleted the close_stderr branch September 6, 2022 17:15
Shrews added a commit to Shrews/ansible-runner that referenced this pull request Sep 7, 2022
* Make sure we close stdout/stderr
* Remove unnecessary flush() calls

(cherry picked from commit 2eab201)
Shrews added a commit to Shrews/ansible-runner that referenced this pull request Sep 7, 2022
* Make sure we close stdout/stderr
* Remove unnecessary flush() calls

(cherry picked from commit 2eab201)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants