Explorar o código

Django <= 1.0.2 doesn't have django.core.cache.parse_backend_uri.

Ask Solem %!s(int64=16) %!d(string=hai) anos
pai
achega
cf1498f6d5
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  1. 7 1
      celery/worker.py

+ 7 - 1
celery/worker.py

@@ -78,7 +78,13 @@ def jail(task_id, func, args, kwargs):
     # instead of libmemcache (cmemcache). Should find a better solution for
     # this, but for now "memcached" should probably be unique enough of a
     # string to not make problems.
-    if "memcached" in cache.parse_backend_uri(cache.settings.CACHE_BACKEND)[0]:
+    cache_backend = cache.settings.CACHE_BACKEND
+    if hasattr(cache, "parse_backend_uri"):
+        cache_scheme = cache.parse_backend_uri(cache_backend)[0]
+    else:
+        # Django <= 1.0.2
+        cache_scheme = cache_backend.split(":", 1)[0]
+    if "memcached" in scheme:
         cache.cache.close()
 
     # Backend process cleanup