-
Notifications
You must be signed in to change notification settings - Fork 970
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
Conversation
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]>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
@m1racoli not sure why the checks are not running, could you try pushing the branch again? |
Awesome work, congrats on your first merged pull request! |
…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]>
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.