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

Improving file handle life cycle #5831

Merged
merged 1 commit into from
Sep 2, 2022
Merged

Conversation

jeremyf
Copy link
Contributor

@jeremyf jeremyf commented Sep 2, 2022

What follows is speculation, but informed by the File.open documentation.

Prior to this commit, there was no guarantee that once we opened a file,
we would close it. This means that as this process ran we could
accumulate open file handles on the system.

By switching to the File.open { |file| ... } approach the
aforementioned block will ensure that we close the file when the block
terminates.

Note: This came about in trying to debug the callstack for
ruby2-6 (65220) - samvera/hyrax

@samvera/hyrax-code-reviewers

What follows is speculation, but informed by the [File.open documentation][1].

Prior to this commit, there was no guarantee that once we opened a file,
we would close it.  This means that as this process ran we could
accumulate open file handles on the system.

By switching to the `File.open { |file| ... }` approach the
aforementioned block will ensure that we close the file when the block
terminates.

Note: This came about in trying to debug the callstack for
[ruby2-6 (65220) - samvera/hyrax][2]

[1]:https://ruby-doc.org/core-2.7.2/File.html#method-c-open
[2]:https://app.circleci.com/pipelines/github/samvera/hyrax/8274/workflows/26246722-a8e8-43a0-a1fa-7b32db139856/jobs/65220
Copy link
Member

@cjcolvar cjcolvar left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@dlpierce dlpierce added the notes-bugfix Release Notes: Fixed a bug label Sep 2, 2022
@dlpierce dlpierce merged commit f9bc8c8 into main Sep 2, 2022
@dlpierce dlpierce deleted the improving-file-handle-lifecycle branch September 2, 2022 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes-bugfix Release Notes: Fixed a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants