Skip to content

Commit

Permalink
Merge pull request #9561 from rtibbles/cache_me_if_you_can
Browse files Browse the repository at this point in the history
Move CACHES import into function scope to prevent side effects.
  • Loading branch information
rtibbles committed Jul 15, 2022
2 parents d150cb3 + ec849f5 commit 296ced9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kolibri/utils/main.py
Expand Up @@ -25,7 +25,6 @@
from kolibri.core.upgrade import matches_version
from kolibri.core.upgrade import run_upgrades
from kolibri.core.utils.cache import process_cache
from kolibri.deployment.default.cache import CACHES
from kolibri.deployment.default.sqlite_db_names import ADDITIONAL_SQLITE_DATABASES
from kolibri.plugins.utils import autoremove_unavailable_plugins
from kolibri.plugins.utils import check_plugin_config_file_location
Expand Down Expand Up @@ -225,6 +224,10 @@ def _upgrades_before_django_setup(updated, version):


def _post_django_initialization():
# Import here to prevent the module level access to Kolibri options
# which causes premature registration of Kolibri plugins.
from kolibri.deployment.default.cache import CACHES

if "process_cache" in CACHES: # usually it means not using redis
if "DatabaseCache" not in CACHES["process_cache"]["BACKEND"]:
try:
Expand Down

0 comments on commit 296ced9

Please sign in to comment.