release lock properly if segment conversion crashes

This commit is contained in:
Antoine Beaupré 2015-10-01 14:22:29 -04:00
parent 3bb3bd45fc
commit 6a72252b69
1 changed files with 5 additions and 3 deletions

View File

@ -27,9 +27,11 @@ class AtticRepositoryConverter(Repository):
# partial open: just hold on to the lock
self.lock = UpgradableLock(os.path.join(self.path, 'lock'),
exclusive=True).acquire()
self.convert_segments(segments, dryrun)
self.lock.release()
self.lock = None
try:
self.convert_segments(segments, dryrun)
finally:
self.lock.release()
self.lock = None
self.convert_cache(dryrun)
@staticmethod