Skip to content

Commit

Permalink
fix: more debugging of memcached client
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Sep 29, 2023
1 parent 874c39c commit 7358451
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions enterprise_catalog/apps/api_client/discovery_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ def _get_catalog_query_metadata(self, catalog_query):
# Debugging: force ignore_exc off to see what exception is getting raise
# on the cache adds.
if hasattr(cache, '_options'):
cache._options['ignore_exc'] = False # pylint: disable=protected-access
# Access and invalidate the @cached_property _cache attribute.
# This will force the django memcached.py backend to recompute
# a pymemcache client for us with updated options.
# See Django's `BaseMemcachedCache` implementation.

# pylint: disable=protected-access
_ = cache._cache
del cache._cache
cache._options['ignore_exc'] = False
LOGGER.info('Cache instance options %s', cache._options)
cache_add_success = False
try:
cache_add_success = cache.add(
Expand All @@ -78,10 +87,16 @@ def _get_catalog_query_metadata(self, catalog_query):
settings.DISCOVERY_CATALOG_QUERY_CACHE_TIMEOUT,
)
except Exception as exc: # pylint: disable=broad-except
LOGGER.exception('Cache add fail %s', exc)
LOGGER.exception('Cache add did not succeed %s', exc)
finally:
if hasattr(cache, '_options'):
cache._options['ignore_exc'] = True # pylint: disable=protected-access
# pylint: disable=protected-access
cache._options['ignore_exc'] = True
# Access and invalidate as above, so the next
# user of django.core.cache.cache has the expected
# set of options from Django settings.
_ = cache._cache
del cache._cache

if cache_add_success:
LOGGER.info(
Expand Down

0 comments on commit 7358451

Please sign in to comment.