[Erp5-report] r28758 - /erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Sep 2 18:24:21 CEST 2009


Author: kazuhiko
Date: Wed Sep  2 18:24:19 2009
New Revision: 28758

URL: http://svn.erp5.org?rev=28758&view=rev
Log:
create a new connection if the existing connection seems dead.

Modified:
    erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py

Modified: erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py?rev=28758&r1=28757&r2=28758&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py [utf8] Wed Sep  2 18:24:19 2009
@@ -31,7 +31,7 @@
 Memcached based cache plugin.
 """
 from thread import get_ident
-from zLOG import LOG
+from zLOG import LOG, WARNING
 from BaseCache import BaseCache
 from BaseCache import CacheEntry
 from Products.ERP5Type import interfaces
@@ -77,6 +77,17 @@
     thread_id = get_ident()
 
     memcache_conn = connection_pool.get(thread_id, None)
+    if memcache_conn is not None:
+      stats = memcache_conn.get_stats()
+      if not len(stats) or not len(stats[0][1]):
+        # create a new connection if the existing connection seems
+        # dead.
+        # XXX Since python-memcached does not raise an exception in such
+        # a case, we check here by calling get_stats(), but it will take
+        # a bit more time for each getCacheStorage() call.
+        LOG('DistributedRamCache', WARNING, 'the existing connection seems dead. a new connection will be created.')
+        memcache_conn.disconnect_all()
+        memcache_conn = None
     if memcache_conn is None:
       ## we don't have memcache_conn for this thread
       memcache_conn = memcache.Client(self._servers.split('\n'),




More information about the Erp5-report mailing list