Move PDB.close out of the sqlmixin, into main class.

Doesn't really deserve to be with the sql stuff.
This commit is contained in:
voussoir 2018-07-15 13:27:04 -07:00
parent 5c97086df3
commit 57a9e0d4dc

View file

@ -675,17 +675,6 @@ class PDBSQLMixin:
self.on_commit_queue = []
self.savepoints = []
def close(self):
# Wrapped in hasattr because if the object fails __init__, Python will
# still call __del__ and thus close(), even though the attributes
# we're trying to clean up never got set.
if hasattr(self, 'sql'):
self.sql.close()
if hasattr(self, 'ephemeral'):
if self.ephemeral:
self.ephemeral_directory.cleanup()
def commit(self):
while len(self.on_commit_queue) > 0:
task = self.on_commit_queue.pop()
@ -1363,6 +1352,16 @@ class PhotoDB(
self._cached_frozen_children = None
self._cached_qualname_map = None
def close(self):
# Wrapped in hasattr because if the object fails __init__, Python will
# still call __del__ and thus close(), even though the attributes
# we're trying to clean up never got set.
if hasattr(self, 'sql'):
self.sql.close()
if getattr(self, 'ephemeral', False):
self.ephemeral_directory.cleanup()
def generate_id(self, table):
'''
Create a new ID number that is unique to the given table.