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.
Why are these changes needed?
This makes
unittest
logs easier to read which can reduce iteration time.The GPU one should be uncontroversial.
I added a wait after forcibly killing a subprocess; this doesn't guarantee that the ResourceWarning goes away, but it fixed it for me. Might be better to change the subprocess so it responds to SIGTERM more quickly, but that would take more effort.
The remaining changes close log files after passing them to subprocesses. I noticed a comment on #10279 which claims that they were kept open deliberately. It's possible that I'm missing something, but I think the files are only used by these subprocesses, and most OSs I'm aware of will keep file descriptors open in child processes after the parent closes them. In any case
subprocess.Popen
duplicates these handles before passing them to the child on POSIX [1] and Windows [2].[1] https://github.com/python/cpython/blob/07119dd38c9a6e5da84ca8a0a46acdf8a3e60ecf/Lib/subprocess.py#L1541
[2] https://github.com/python/cpython/blob/07119dd38c9a6e5da84ca8a0a46acdf8a3e60ecf/Lib/subprocess.py#L1208
Related issue number
Closes #9546 and #10279.
Checks
scripts/format.sh
to lint the changes in this PR.