Skip to content

Commit

Permalink
Fix ResourceWarnings in FileStorage.pack()
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Mar 1, 2013
1 parent b07519b commit 033512a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ZODB/FileStorage/FileStorage.py
Expand Up @@ -1034,10 +1034,13 @@ def packer(storage, referencesf, stop, gc):
# want to invest much in the old packer, at least for now.
assert referencesf is not None
p = FileStoragePacker(storage, referencesf, stop, gc)
opos = p.pack()
if opos is None:
return None
return opos, p.index
try:
opos = p.pack()
if opos is None:
return None
return opos, p.index
finally:
p.close()

def pack(self, t, referencesf, gc=None):
"""Copy data from the current database file to a packed file
Expand Down
9 changes: 9 additions & 0 deletions src/ZODB/FileStorage/fspack.py
Expand Up @@ -382,6 +382,15 @@ def __init__(self, storage, referencesf, stop, gc=True):
self.toid2tid = {}
self.toid2tid_delete = {}

self._tfile = None

def close(self):
self._file.close()
if self._tfile is not None:
self._tfile.close()
if self.blob_removed is not None:
self.blob_removed.close()

def pack(self):
# Pack copies all data reachable at the pack time or later.
#
Expand Down

0 comments on commit 033512a

Please sign in to comment.