[CalendarServer-changes] [4013] CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 13 17:56:23 PDT 2009
Revision: 4013
http://trac.macosforge.org/projects/calendarserver/changeset/4013
Author: sagen at apple.com
Date: 2009-04-13 17:56:22 -0700 (Mon, 13 Apr 2009)
Log Message:
-----------
Handle failed memcache get()
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py
Modified: CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py 2009-04-14 00:48:34 UTC (rev 4012)
+++ CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py 2009-04-14 00:56:22 UTC (rev 4013)
@@ -145,6 +145,7 @@
self.cacheTimeout = cacheTimeout * 60
self._initCaches(cacheClass)
+ super(CachingDirectoryService, self).__init__()
def _getMemcacheClient(self, refresh=False):
if refresh or not hasattr(self, "memcacheClient"):
@@ -182,9 +183,18 @@
return None
key = base64.b64encode(key)
- record = self._getMemcacheClient().get(key)
- if record is not None and isinstance(record, DirectoryRecord):
- record.service = self
+ try:
+ record = self._getMemcacheClient().get(key)
+ if record is not None and isinstance(record, DirectoryRecord):
+ record.service = self
+ except memcache.MemcacheError:
+ self.log_error("Could not read from memcache, retrying")
+ try:
+ record = self._getMemcacheClient(refresh=True).get(key, record)
+ except memcache.MemcacheError:
+ self.log_error("Could not read from memcache again, giving up")
+ del self.memcacheClient
+ raise DirectoryMemcacheError("Failed to read from memcache")
return record
def _initCaches(self, cacheClass):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090413/2bd0c674/attachment.html>
More information about the calendarserver-changes
mailing list