Handle error when loading actor from cache

master
Bob Mottram 2019-09-02 12:20:15 +01:00
parent db9685b2f5
commit 3d6a823da8
1 changed files with 8 additions and 2 deletions

View File

@ -37,8 +37,14 @@ def getPersonFromCache(baseDir: str,personUrl: str,personCache: {}) -> {}:
if not personCache.get(personUrl): if not personCache.get(personUrl):
cacheFilename=baseDir+'/cache/actors/'+personUrl.replace('/','#')+'.json' cacheFilename=baseDir+'/cache/actors/'+personUrl.replace('/','#')+'.json'
if os.path.isfile(cacheFilename): if os.path.isfile(cacheFilename):
with open(cacheFilename, 'r') as fp: personJson=None
personJson=commentjson.load(fp) 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) storePersonInCache(baseDir,personUrl,personJson,personCache)
loadedFromFile=True loadedFromFile=True