Pārlūkot izejas kodu

Work only closes cache connection now if memcached is the cache backend

Vitaly Babiy 16 gadi atpakaļ
vecāks
revīzija
b704e18d4a
1 mainītis faili ar 4 papildinājumiem un 4 dzēšanām
  1. 4 4
      celery/worker.py

+ 4 - 4
celery/worker.py

@@ -72,10 +72,10 @@ def jail(task_id, func, args, kwargs):
     from django.db import connection
     connection.close()
 
-    # Reset cache connection
-    from django.core.cache import cache, backends
-    if not isinstance(cache,backends.locmem.CacheClass):
-        cache.close()
+    # Reset cache connection only if using memcached
+    from django.core import cache
+    if cache.parse_backend_uri(cache.settings.CACHE_BACKEND)[0] == 'memcached':
+        cache.cache.close()
 
     # Backend process cleanup
     default_backend.cleanup_process()