From 750d448799d52fc0d3a9581cf32acbdacac81767 Mon Sep 17 00:00:00 2001 From: Renzo Lucioni Date: Tue, 9 May 2017 17:22:13 -0400 Subject: [PATCH] Avoid passing a generator expression to cache.get_many() Generator expressions passed to the memcached backend's implementation of get_many() are exhausted prematurely. This results in KeyErrors when the backend tries to map keys returned by memcached back to keys passed by application code. See https://github.com/django/django/blob/stable/1.8.x/django/core/cache/backends/memcached.py/#L99. LEARNER-382 --- openedx/core/djangoapps/catalog/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/catalog/utils.py b/openedx/core/djangoapps/catalog/utils.py index 37b7dbe9c3..eb4376cb4b 100644 --- a/openedx/core/djangoapps/catalog/utils.py +++ b/openedx/core/djangoapps/catalog/utils.py @@ -53,7 +53,7 @@ def get_programs(uuid=None): if not uuids: logger.warning('Program UUIDs are not cached.') - programs = cache.get_many(PROGRAM_CACHE_KEY_TPL.format(uuid=uuid) for uuid in uuids) + programs = cache.get_many([PROGRAM_CACHE_KEY_TPL.format(uuid=uuid) for uuid in uuids]) programs = list(programs.values()) missing_uuids = set(uuids) - set(program['uuid'] for program in programs)