From 3d6a823da8b59db018f78f3f0d8b40e18554e529 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 2 Sep 2019 12:20:15 +0100 Subject: [PATCH] Handle error when loading actor from cache --- cache.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cache.py b/cache.py index 36b45b26..5b9dbe42 100644 --- a/cache.py +++ b/cache.py @@ -37,8 +37,14 @@ def getPersonFromCache(baseDir: str,personUrl: str,personCache: {}) -> {}: if not personCache.get(personUrl): cacheFilename=baseDir+'/cache/actors/'+personUrl.replace('/','#')+'.json' if os.path.isfile(cacheFilename): - with open(cacheFilename, 'r') as fp: - personJson=commentjson.load(fp) + personJson=None + try: + with open(cacheFilename, 'r') as fp: + personJson=commentjson.load(fp) + except Exception as e: + print('ERROR: unable to load actor from cache '+cacheFilename) + print(e) + if personJson: storePersonInCache(baseDir,personUrl,personJson,personCache) loadedFromFile=True