Commit be80e005 by Jason Bau

Merge pull request #4464 from edx/jbau/remove-branch-setting-cache

removing thread-local cache for branch_setting
parents e81c33ce f12fa05a
......@@ -136,10 +136,6 @@ class ModuleI18nService(object):
return strftime_localized(*args, **kwargs)
# thread local cache
_THREAD_CACHE = threading.local()
def _get_modulestore_branch_setting():
"""
Returns the branch setting for the module store from the current Django request if configured,
......@@ -167,7 +163,6 @@ def _get_modulestore_branch_setting():
branch = getattr(settings, 'MODULESTORE_BRANCH', None)
return branch
# cache the branch setting for this thread so we don't have to recompute it each time
if not hasattr(_THREAD_CACHE, 'branch_setting'):
_THREAD_CACHE.branch_setting = get_branch_setting()
return _THREAD_CACHE.branch_setting
# leaving this in code structured in closure-friendly format b/c we might eventually cache this (again)
# using request_cache
return get_branch_setting()
......@@ -47,16 +47,6 @@ class CoursesTest(ModuleStoreTestCase):
class ModuleStoreBranchSettingTest(ModuleStoreTestCase):
"""Test methods related to the modulestore branch setting."""
def cleanup_branch_setting(self):
if hasattr(store_django._THREAD_CACHE, 'branch_setting'):
delattr(store_django._THREAD_CACHE, 'branch_setting')
def setUp(self):
self.cleanup_branch_setting()
def tearDown(self):
self.cleanup_branch_setting()
@mock.patch(
'xmodule.modulestore.django.get_current_request_hostname',
mock.Mock(return_value='preview.localhost')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment