diff --git a/app/chain/__init__.py b/app/chain/__init__.py index c33c3b514..bcc28686d 100644 --- a/app/chain/__init__.py +++ b/app/chain/__init__.py @@ -38,7 +38,10 @@ 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 @@ -46,7 +49,10 @@ 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: """