-
Notifications
You must be signed in to change notification settings - Fork 39
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
Stop resource leakage when reading conf files #2451
Conversation
This should fix the annoying ResourceWarnings coming through during the test suite: /source/python/nav/config.py:339: ResourceWarning: unclosed file <_io.TextIOWrapper name='/source/.tox/integration-py37-django32/etc/nav.conf' mode='r' encoding='utf-8'> NAV_CONFIG = read_flat_config('nav.conf') ResourceWarning: Enable tracemalloc to get the object allocation traceback /source/python/nav/django/settings.py:36: ResourceWarning: unclosed file <_io.TextIOWrapper name='/source/.tox/integration-py37-django32/etc/webfront/webfront.conf' mode='r' encoding='utf-8'> _webfront_config = getconfig('webfront/webfront.conf') ResourceWarning: Enable tracemalloc to get the object allocation traceback /source/python/nav/db/__init__.py:104: ResourceWarning: unclosed file <_io.TextIOWrapper name='/source/.tox/integration-py37-django32/etc/db.conf' mode='r' encoding='utf-8'> conf = config.read_flat_config('db.conf') ResourceWarning: Enable tracemalloc to get the object allocation traceback
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Codecov Report
@@ Coverage Diff @@
## master #2451 +/- ##
=======================================
Coverage 52.72% 52.73%
=======================================
Files 552 552
Lines 40186 40188 +2
=======================================
+ Hits 21190 21192 +2
Misses 18996 18996
|
For the functional tests this error message still appears:
|
Possibly, but this is not a config file leakage, it's part of the test suite setup, and does not affect production code (i.e. separate PR, at best) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as intended 👍
This should fix the annoying ResourceWarnings coming through during the test suite:
This PR just ensures we wrap the config-reading code in a context manager so the config files always end up being closed.