Handle other places where we might be unpickling things.
We use pickling in conjunction with caches in these cases so we should be able to fallback to the uncached behavior if the pickled data is corrupt in some way. eg. it's a python 2 pickle we don't know how to read.
This commit is contained in:
@@ -56,11 +56,16 @@ def get_edx_api_data(api_config, resource, api, resource_id=None, querystring=No
|
||||
|
||||
cached = cache.get(cache_key)
|
||||
if cached:
|
||||
cached_response = zunpickle(cached)
|
||||
if fields:
|
||||
cached_response = get_fields(fields, cached_response)
|
||||
try:
|
||||
cached_response = zunpickle(cached)
|
||||
if fields:
|
||||
cached_response = get_fields(fields, cached_response)
|
||||
|
||||
return cached_response
|
||||
return cached_response
|
||||
except Exception:
|
||||
# Data is corrupt in some way.
|
||||
log.warning("Data for cache is corrupt for cache key %s", cache_key)
|
||||
cache.delete(cache_key)
|
||||
|
||||
try:
|
||||
endpoint = getattr(api, resource)
|
||||
|
||||
Reference in New Issue
Block a user