Ensure files are always closed after use#5346
Open
aakallam wants to merge 1 commit into
Open
Conversation
dd606d1 to
79d5a0e
Compare
79d5a0e to
46a8e8c
Compare
dylanjew
approved these changes
Jul 9, 2026
| finally: | ||
| # Don't need the archive after writing testcase to blobstore. | ||
| if zip_path: | ||
| shell.remove_file(zip_path) |
Collaborator
There was a problem hiding this comment.
Is there a similar way we can handle file clean up?
Collaborator
Author
There was a problem hiding this comment.
Do you mean for the testcase files or something else?
Collaborator
There was a problem hiding this comment.
I thought it was strange that we're manually calling remove_file(zip_path) in a couple places but I'm not sure of a way around that.
either way cleaning up the file usage LGTM
dylanjew
approved these changes
Jul 9, 2026
| finally: | ||
| # Don't need the archive after writing testcase to blobstore. | ||
| if zip_path: | ||
| shell.remove_file(zip_path) |
Collaborator
There was a problem hiding this comment.
I thought it was strange that we're manually calling remove_file(zip_path) in a couple places but I'm not sure of a way around that.
either way cleaning up the file usage LGTM
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 is a follow up to #5342 that refactors a bunch of file I/O to use
withstatements to ensure that the file handles are always closed. Closing file handles is especially important on Windows because only one file object can point at a file at one time.To make a few complex file opening cases work, this PR adds a couple new path variables to simplify the refactoring but otherwise does not introduce or change any logic.