Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into built-in-unpickler
Browse files Browse the repository at this point in the history
  • Loading branch information
kavigupta committed Oct 15, 2024
2 parents b717a59 + 36c6768 commit 01bbf2e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion permacache/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import shutil
import sys
from pickle import UnpicklingError

from appdirs import user_cache_dir

Expand Down Expand Up @@ -44,7 +46,14 @@ def __call__(self, *args, **kwargs):

with self.shelf as db:
if key in db:
return db[key]
try:
return db[key]
except UnpicklingError as e:
# total hack. not sure why this is happening
print(f"Unpickling error: {e}", file=sys.stderr)
print(repr(key), file=sys.stderr)
print("Deleting key", file=sys.stderr)
del db[key]
value = self._run_underlying(*args, **kwargs)
with self.shelf as db:
# TODO maybe check if key is now in db
Expand Down

0 comments on commit 01bbf2e

Please sign in to comment.