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):
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