Skip to content

fix: open file in read mode and close on cleanup for ElasticsearchPublisher #2023

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

Merged
merged 4 commits into from
Jan 31, 2023

Conversation

m1racoli
Copy link
Contributor

@m1racoli m1racoli commented Nov 7, 2022

  • fix: open file in read mode
  • fix: close file handler on cleanup

Summary of Changes

Since we only read from the file, we do not need to open it in write mode. Furthermore we close the file on cleanup in order to avoid issues with open file handlers. In particular this affects the automatic cleanup of temporary directories containing the file.

Continuation of stale PR #1920

Tests

This affects low level aspect of how we open and close files, which might be beyond the scope of tests.

Documentation

Nothing to document as there is not effective change in behaviour.

CheckList

Make sure you have checked all steps below to ensure a timely review.

  • PR title addresses the issue accurately and concisely. Example: "Updates the version of Flask to v1.0.2"
  • PR includes a summary of changes.
  • PR adds unit tests, updates existing unit tests, OR documents why no test additions or modifications are needed.
  • In case of new functionality, my PR adds documentation that describes how to use it.
    • All the public functions and the classes in the PR contain docstrings that explain what it does

Cedrik Neumann and others added 4 commits March 23, 2022 09:34
We only read from the file and therefore should not open it in write mode.

Signed-off-by: Cedrik Neumann <[email protected]>
Not closing the file can cause several issues. One of them is that it
prevents [temporary directories](https://docs.python.org/3.10/library/tempfile.html#tempfile.TemporaryDirectory) containing the file from automatic deletion.

Signed-off-by: Cedrik Neumann <[email protected]>
@m1racoli m1racoli requested a review from a team as a code owner November 7, 2022 10:53
@boring-cyborg boring-cyborg bot added the area:databuilder From databuilder folder label Nov 7, 2022
@stale
Copy link

stale bot commented Nov 22, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Nov 22, 2022
@Golodhros Golodhros removed the stale label Dec 15, 2022
@stale
Copy link

stale bot commented Dec 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Dec 31, 2022
@Golodhros Golodhros added the keep fresh Disables stalebot from closing an issue label Jan 3, 2023
@stale stale bot removed the stale label Jan 3, 2023
@Golodhros
Copy link
Member

@m1racoli not sure why the checks are not running, could you try pushing the branch again?

@Golodhros Golodhros closed this Jan 31, 2023
@Golodhros Golodhros reopened this Jan 31, 2023
@Golodhros Golodhros merged commit e2f5f5a into amundsen-io:main Jan 31, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 31, 2023

Awesome work, congrats on your first merged pull request!

@m1racoli m1racoli deleted the fix-es-publisher branch February 2, 2023 15:11
B-T-D pushed a commit to B-T-D/amundsen that referenced this pull request Mar 29, 2023
…lisher (amundsen-io#2023)

* fix(ElasticsearchPublisher): open file in read mode

We only read from the file and therefore should not open it in write mode.

Signed-off-by: Cedrik Neumann <[email protected]>

* fix(ElasticsearchPublisher): close file on cleanup

Not closing the file can cause several issues. One of them is that it
prevents [temporary directories](https://docs.python.org/3.10/library/tempfile.html#tempfile.TemporaryDirectory) containing the file from automatic deletion.

Signed-off-by: Cedrik Neumann <[email protected]>

---------

Signed-off-by: Cedrik Neumann <[email protected]>
Signed-off-by: Ben Dye <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:databuilder From databuilder folder keep fresh Disables stalebot from closing an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants