Browse Source

Can't exact match for "memcached". Search for it as a substring instead.
At Opera we use a custom cache backend that uses libmemcached 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.

Ask Solem 16 năm trước cách đây
mục cha
commit
de36431b07
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      celery/worker.py

+ 6 - 2
celery/worker.py

@@ -72,9 +72,13 @@ def jail(task_id, func, args, kwargs):
     from django.db import connection
     connection.close()
 
-    # Reset cache connection only if using memcached
+    # Reset cache connection only if using memcached/libmemcached
     from django.core import cache
-    if cache.parse_backend_uri(cache.settings.CACHE_BACKEND)[0] == 'memcached':
+    # XXX At Opera we use a custom memcached backend that uses libmemcached
+    # 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(settings.CACHE_BACKEND)[0]:
         cache.cache.close()
 
     # Backend process cleanup