From 7b23d5f7912299fa7ba7419c6c775f5950d4c7fb Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Wed, 27 Oct 2010 08:30:35 +0000 Subject: [PATCH] workaround for possible too many open memcached connections problem. in _initialiseConnection(), try to disconnect existing connections if exist. python-memcached's get() returns None in case of any error, but it also returns None if None is set, of course. so if 'reconnect' is unfortunately triggered by None value, we should have a living connection at that time. to fix this issue perfectly, we should rewrite memcached client library that raises an Exception in case of exception. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39553 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Tool/MemcachedTool.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/product/ERP5Type/Tool/MemcachedTool.py b/product/ERP5Type/Tool/MemcachedTool.py index 6f86a3d095..2258968b4c 100644 --- a/product/ERP5Type/Tool/MemcachedTool.py +++ b/product/ERP5Type/Tool/MemcachedTool.py @@ -101,6 +101,10 @@ if memcache is not None: self._initialiseConnection() def _initialiseConnection(self): + try: + self.memcached_connection.disconnect_all() + except AttributeError: + pass init_dict = {} if self.server_max_key_length is not MARKER: init_dict['server_max_key_length'] = self.server_max_key_length -- 2.30.9