浏览代码

Cache: do not try to release the lock twice

If Cache was already closed and __del__ was called, it called close() again
and crashed when trying to release the lock again.
Thomas Waldmann 10 年之前
父节点
当前提交
d3fe74d4c0
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      attic/cache.py

+ 4 - 1
attic/cache.py

@@ -18,6 +18,7 @@ class Cache(object):
 
     def __init__(self, repository, key, manifest, path=None, sync=True):
         self.timestamp = None
+        self.lock = None
         self.txn_active = False
         self.repository = repository
         self.key = key
@@ -69,7 +70,9 @@ class Cache(object):
         self.files = None
 
     def close(self):
-        self.lock.release()
+        if self.lock:
+            self.lock.release()
+            self.lock = None
 
     def _read_files(self):
         self.files = {}