Catches BlockStructureNotFound raised when clearing course from cache

This commit is contained in:
Nizar Mahmoud
2020-11-07 13:40:42 +03:00
parent c74b623948
commit e4c8897014

View File

@@ -2,6 +2,7 @@
Signal handlers for invalidating cached data.
"""
import logging
import six
from django.conf import settings
@@ -12,8 +13,11 @@ from xmodule.modulestore.django import SignalHandler
from . import config
from .api import clear_course_from_cache
from .models import BlockStructureNotFound
from .tasks import update_course_in_cache_v2
log = logging.getLogger(__name__)
@receiver(SignalHandler.course_published)
def update_block_structure_on_course_publish(sender, course_key, **kwargs): # pylint: disable=unused-argument
@@ -26,7 +30,13 @@ def update_block_structure_on_course_publish(sender, course_key, **kwargs): # p
return
if config.waffle().is_enabled(config.INVALIDATE_CACHE_ON_PUBLISH):
clear_course_from_cache(course_key)
try:
clear_course_from_cache(course_key)
except BlockStructureNotFound:
log.warning(
u"BlockStructure: %s not found when trying to clear course from cache",
course_key,
)
update_course_in_cache_v2.apply_async(
kwargs=dict(course_id=six.text_type(course_key)),