From 19188fd039ab7fa0656a199d49b91f78fbffac52 Mon Sep 17 00:00:00 2001
From: Nicolas Dumazet <nicolas.dumazet@nexedi.com>
Date: Mon, 13 Dec 2010 05:34:37 +0000
Subject: [PATCH] do not die completely if memcached server isnt here

Raising KeyError means more cache misses, and it's acceptable:
on the other hand crashing an instance just because you install
a BT that has a memcache cache configured that can't access
the memcache daemon was just wrong.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41372 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Tool/MemcachedTool.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Type/Tool/MemcachedTool.py b/product/ERP5Type/Tool/MemcachedTool.py
index 1c2b5a38b6..472c52ccd7 100644
--- a/product/ERP5Type/Tool/MemcachedTool.py
+++ b/product/ERP5Type/Tool/MemcachedTool.py
@@ -184,7 +184,14 @@ if memcache is not None:
           result = self.memcached_connection.get(encoded_key)
         except memcache.Client.MemcachedConnectionError:
           self._initialiseConnection()
-          result = self.memcached_connection.get(encoded_key)
+          try:
+            result = self.memcached_connection.get(encoded_key)
+          except memcache.Client.MemcachedConnectionError:
+            # maybe the server is not available at all / misconfigured
+            LOG('MemcacheTool', 0,
+                'get command to memcached server (%r) failed'
+                % (self.server_list,))
+            raise KeyError
         self.local_cache[key] = result
       return result
 
-- 
2.30.9