From 7acae1e45be4feac280741804b7fd20163e086ef Mon Sep 17 00:00:00 2001 From: Thor77 Date: Sat, 31 Mar 2018 20:59:45 +0200 Subject: [PATCH] Catch KeyError from pickle.load and log exception as warning instead of debug. KeyError seems to occur in Python2 instead of an UnpicklingError --- tsstats/cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsstats/cache.py b/tsstats/cache.py index 08dfb11..9da48b4 100644 --- a/tsstats/cache.py +++ b/tsstats/cache.py @@ -58,8 +58,8 @@ class Cache(MutableMapping): with open(path, 'rb') as f: try: data = pickle.load(f) - except EOFError or pickle.UnpicklingError: - logger.debug('Couldn\'t read cache') + except (EOFError, pickle.UnpicklingError, KeyError): + logger.warning('Couldn\'t read cache') return cls(path, data) def write(self, path=None):