Skip to content

Conversation

@dhirving
Copy link
Contributor

Add a close() method and a context manager implementation to Butler, to prevent resource leaks. This allows users to ensure that database connections are closed promptly.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes
  • (if changing dimensions.yaml) make a copy of dimensions.yaml in configs/old_dimensions

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 78.93891% with 131 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.45%. Comparing base (f17f41f) to head (b9ecf4b).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
python/lsst/daf/butler/script/exportCalibs.py 0.00% 31 Missing ⚠️
python/lsst/daf/butler/script/queryCollections.py 76.40% 18 Missing and 3 partials ⚠️
...thon/lsst/daf/butler/script/certifyCalibrations.py 0.00% 14 Missing ⚠️
...on/lsst/daf/butler/script/queryDimensionRecords.py 69.04% 5 Missing and 8 partials ⚠️
python/lsst/daf/butler/script/queryDataIds.py 80.00% 7 Missing and 3 partials ⚠️
python/lsst/daf/butler/script/collectionChain.py 58.82% 3 Missing and 4 partials ⚠️
python/lsst/daf/butler/script/transferDatasets.py 0.00% 7 Missing ⚠️
python/lsst/daf/butler/script/_associate.py 0.00% 4 Missing ⚠️
python/lsst/daf/butler/script/queryDatasetTypes.py 69.23% 3 Missing and 1 partial ⚠️
python/lsst/daf/butler/_labeled_butler_factory.py 91.17% 1 Missing and 2 partials ⚠️
... and 9 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1288      +/-   ##
==========================================
+ Coverage   89.42%   89.45%   +0.03%     
==========================================
  Files         367      367              
  Lines       49540    49739     +199     
  Branches     5837     5850      +13     
==========================================
+ Hits        44299    44496     +197     
  Misses       3856     3856              
- Partials     1385     1387       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dhirving dhirving force-pushed the tickets/DM-53233 branch 6 times, most recently from c47ff55 to 015b09c Compare November 18, 2025 23:16
Remove a type hint for `DirectButler.datastore`, which is never actually assigned or used.  The actual object is `_datastore`.
Add a close() method and a context manager implementation to Butler, to prevent resource leaks.  This allows users to ensure that database connections are closed promptly.
Ensure that close() is called on all Butler instances created during unit tests, to ensure that file handles associated with database connections are closed promptly.  This fixes an issue where tests could fail due to file descriptor exhaustion.
Eliminate circular references from Butler instances so that it gets garbage collected immediately when it goes out of scope.
Add a close() method to allow cleanup of QuantumBackedButler's internal sqlite instance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants