diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index f061b327eb..8c28306ad6 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -226,9 +226,12 @@ class BaseInvenTreeSetting(models.Model): """ cache_key = f'BUILD_DEFAULT_VALUES:{str(cls.__name__)}' - if InvenTree.helpers.str2bool(cache.get(cache_key, False)): - # Already built default values - return + try: + if InvenTree.helpers.str2bool(cache.get(cache_key, False)): + # Already built default values + return + except Exception: + pass try: existing_keys = cls.objects.filter(**kwargs).values_list('key', flat=True) @@ -251,7 +254,10 @@ class BaseInvenTreeSetting(models.Model): ) pass - cache.set(cache_key, True, timeout=3600) + try: + cache.set(cache_key, True, timeout=3600) + except Exception: + pass def _call_settings_function(self, reference: str, args, kwargs): """Call a function associated with a particular setting. diff --git a/InvenTree/common/settings.py b/InvenTree/common/settings.py index a0e888fd8b..3380def996 100644 --- a/InvenTree/common/settings.py +++ b/InvenTree/common/settings.py @@ -34,7 +34,10 @@ def currency_code_default(): code = 'USD' # pragma: no cover # Cache the value for a short amount of time - cache.set('currency_code_default', code, 30) + try: + cache.set('currency_code_default', code, 30) + except Exception: + pass return code diff --git a/InvenTree/users/models.py b/InvenTree/users/models.py index 97723613db..701b7e8105 100644 --- a/InvenTree/users/models.py +++ b/InvenTree/users/models.py @@ -748,7 +748,11 @@ def check_user_role(user, role, permission): break # Save result to cache - cache.set(key, result, timeout=3600) + try: + cache.set(key, result, timeout=3600) + except Exception: + pass + return result