mirror of
https://github.com/powerline/powerline.git
synced 2025-07-23 05:46:01 +02:00
Reset memoize cache if unable to unpickle
This is usually due to the cache being stored with Python 3 and then attempted to being loaded in Python 2 which raises a ValueError. Closes #138.
This commit is contained in:
parent
38195f490e
commit
d6da2c8d98
@ -29,8 +29,8 @@ class memoize(object):
|
||||
try:
|
||||
with open(self.persistent_file, 'rb') as fileobj:
|
||||
self._cache = pickle.load(fileobj)
|
||||
except (IOError, EOFError):
|
||||
pass
|
||||
except (IOError, EOFError, ValueError):
|
||||
self._cache = {}
|
||||
cached = self._cache.get(key, None)
|
||||
if cached is None or time.time() - cached['time'] > self.timeout:
|
||||
cached = self._cache[key] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user