Index: client/named_cache.py |
diff --git a/client/named_cache.py b/client/named_cache.py |
index 50a4e1c04fb9005f5d4a83150f3ee405f0044e63..e62062595a2951cfee5551a2115a5b4db665b204 100644 |
--- a/client/named_cache.py |
+++ b/client/named_cache.py |
@@ -63,12 +63,17 @@ class CacheManager(object): |
Returns a context manager that must be closed as soon as possible. |
""" |
- state_path = os.path.join(self.root_dir, u'state.json') |
with self._lock: |
+ state_path = os.path.join(self.root_dir, u'state.json') |
+ assert self._lru is None, 'acquired lock, but self._lru is not None' |
if os.path.isfile(state_path): |
- self._lru = lru.LRUDict.load(state_path) |
- else: |
- self._lru = lru.LRUDict() |
+ try: |
+ self._lru = lru.LRUDict.load(state_path) |
+ except ValueError as ex: |
+ logging.exception('failed to load named cache state file') |
+ logging.warning('deleting named caches') |
+ file_path.rmtree(self.root_dir) |
M-A Ruel
2017/03/17 13:43:41
nit: I'd prefer the directory itself to not be del
nodir
2017/03/17 16:20:56
why? CacheManager works fine if the directory does
M-A Ruel
2017/03/20 23:22:57
I don't know, it's a feeling about simplifying edg
|
+ self._lru = self._lru or lru.LRUDict() |
if time_fn: |
self._lru.time_fn = time_fn |
try: |