def clear_cache_handlers(**kwargs): if kwargs["setting"] == "CACHES": from django.core.cache import caches, close_caches close_caches() caches._settings = caches.settings = caches.configure_settings(None) caches._connections = Local()
def _close_network_connections(): """ Close connections to database and cache before or after forking. Without this, child processes will share these connections and this is not supported. """ from django import db from django.core import cache from django.conf import settings db.connections.close_all() django_redis_close_connection = getattr(settings, 'DJANGO_REDIS_CLOSE_CONNECTION', default_behaviour) settings.DJANGO_REDIS_CLOSE_CONNECTION = True cache.close_caches() if django_redis_close_connection is default_behaviour: delattr(settings, 'DJANGO_REDIS_CLOSE_CONNECTION') else: settings.DJANGO_REDIS_CLOSE_CONNECTION = django_redis_close_connection
def clear_cache_handlers(**kwargs): if kwargs['setting'] == 'CACHES': from django.core.cache import caches, close_caches close_caches() caches._caches = Local()
def clear_cache_handlers(*, setting, **kwargs): if setting == 'CACHES': from django.core.cache import caches, close_caches close_caches() caches._settings = caches.settings = caches.configure_settings(None) caches._connections = Local()