From 18a5ccc3ef621e85a8d02249270bad0a46e3addc Mon Sep 17 00:00:00 2001 From: jamesgetx Date: Fri, 29 Jan 2021 17:27:01 +0800 Subject: [PATCH] fix: load cache error when CacheDecoder object is not callable --- dynamic/discovery.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dynamic/discovery.py b/dynamic/discovery.py index d2f801f29..5c2f4ac45 100644 --- a/dynamic/discovery.py +++ b/dynamic/discovery.py @@ -15,8 +15,10 @@ import os import six import json +import logging import hashlib import tempfile +from functools import partial from collections import defaultdict from abc import abstractmethod, abstractproperty @@ -54,11 +56,12 @@ class Discoverer(object): else: try: with open(self.__cache_file, 'r') as f: - self._cache = json.load(f, cls=CacheDecoder(self.client)) + self._cache = json.load(f, cls=partial(CacheDecoder, self.client)) if self._cache.get('library_version') != __version__: # Version mismatch, need to refresh cache self.invalidate_cache() - except Exception: + except Exception as e: + logging.error("load cache error: %s", e) self.invalidate_cache() self._load_server_info() self.discover()