From 79e43adbc31f8c5461fe69accb61c50de7d9fb00 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 26 Jul 2021 18:11:45 +0300 Subject: [PATCH] exception handling in sco_cache set --- app/scodoc/sco_cache.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/scodoc/sco_cache.py b/app/scodoc/sco_cache.py index ecbf80a69..193ebd68c 100644 --- a/app/scodoc/sco_cache.py +++ b/app/scodoc/sco_cache.py @@ -85,7 +85,7 @@ class ScoDocCache: try: return CACHE.get(cls._get_key(oid)) except pylibmc.Error: - log("Warning: memcached error") + log("Warning: memcached error in get") log(traceback.format_exc()) return None @@ -94,9 +94,13 @@ class ScoDocCache: """Store value""" key = cls._get_key(oid) # log(f"CACHE key={key}, type={type(value)}, timeout={cls.timeout}") - status = CACHE.set(key, value, timeout=cls.timeout) - if not status: - log("Error: cache set failed !") + try: + status = CACHE.set(key, value, timeout=cls.timeout) + if not status: + log("Error: cache set failed !") + except pylibmc.Error: + log("Warning: memcached error in set") + return status @classmethod