| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
With [paths] configured, _prepare_data_for_reporting() creates a
CoverageData(no_disk=True) and appends it to _data_to_close. For no_disk
data, SqliteDb.close() is a no-op unless force=True, and the only caller
that passes force=True is _atexit.
_atexit was only registered from _init_for_start(), which is reachable
only via Coverage.start(). A Coverage object that only reports -- the
`coverage report` CLI, or pytest-cov's never-started combining_cov --
therefore populated _data_to_close and never drained it, so the shared
cache connection was still open at interpreter shutdown:
ResourceWarning: unclosed database
which fails a -Werror job.
Register the handler from _prepare_data_for_reporting() as well, guarded
by a new _atexit_registered flag so start() and reporting cannot register
it twice.
Adds ReportOnlyCleanupTest in tests/test_process.py, which runs
`python -Werror -m coverage report` with [paths] set and asserts the
warning is absent. It fails without the control.py change.
Closes coveragepy#2251
| mapped_data.update(self._data, map_path=self._make_aliases().map) | ||
| self._data = mapped_data | ||
| self._data_to_close.append(mapped_data) | ||
| if not self._atexit_registered: |
There was a problem hiding this comment.
These three lines of code are the same as 655-657. Let's at least make a helper method to do the check-and-register.
Sorry, something went wrong.
There was a problem hiding this comment.
Addressed in 5d05722: extracted the once-only check-and-register into _register_atexit() and use it from both _init_for_start() and report-only data preparation. The targeted process tests pass: 7 passed.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #2251
With [paths] configured, _prepare_data_for_reporting() creates a CoverageData(no_disk=True) and appends it to _data_to_close, but for no_disk data SqliteDb.close() is a no-op unless force=True — and the only caller passing force=True is _atexit, which was registered solely from _init_for_start(). A Coverage that only reports (the coverage report CLI, or pytest-cov's never-started combining_cov) therefore never drained the list, leaving the connection open at shutdown: ResourceWarning: unclosed database, which fails a -Werror job.
This registers the handler from _prepare_data_for_reporting() too, guarded by a new _atexit_registered flag so start-and-report can't register it twice. ReportOnlyCleanupTest in tests/test_process.py runs the issue's reproducer and fails without the control.py change; tests/test_api.py and tests/test_data.py stay green.
This change was prepared with AI assistance; the regression test was run locally and fails without the fix.