Skip to content

Commit

Permalink
close the database connection in SqlRegistry.__del__
Browse files Browse the repository at this point in the history
note that for __del__ to get called the garbage collector must
be triggered after the final reference has been released. in
unit tests this may be done in tearDown by calling gc.collect.

If we find having or closing the open database connection is a
problem in production code, we may need to
add api to butler to explicity release database connections (and
maybe other things like in-memory cached objects).
  • Loading branch information
n8pease committed Sep 1, 2017
1 parent dde7a43 commit 1e3f45f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/lsst/daf/persistence/registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ def __init__(self, conn):
Registry.__init__(self)
self.conn = conn

def __del__(self):
self.conn.close()
super(SqlRegistry, self).__del__()

def lookup(self, lookupProperties, reference, dataId, **kwargs):
"""Perform a lookup in the registry.
Expand Down

0 comments on commit 1e3f45f

Please sign in to comment.