Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Jul 31, 2023
1 parent 4d0b34f commit c902b6a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/chain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,21 @@ def load_cache(filename: str) -> Any:
"""
cache_path = settings.TEMP_PATH / filename
if cache_path.exists():
return pickle.load(cache_path.open('rb'))
try:
return pickle.load(cache_path.open('rb'))
except Exception as err:
logger.error(f"加载缓存 {filename} 出错:{err}")
return None

@staticmethod
def save_cache(cache: Any, filename: str) -> None:
"""
保存缓存到本地
"""
pickle.dump(cache, (settings.TEMP_PATH / filename).open('wb'))
try:
pickle.dump(cache, (settings.TEMP_PATH / filename).open('wb'))
except Exception as err:
logger.error(f"保存缓存 {filename} 出错:{err}")

def run_module(self, method: str, *args, **kwargs) -> Any:
"""
Expand Down

0 comments on commit c902b6a

Please sign in to comment.