From 4c224318661b2b15f2ba464c7815ad46b9ed9255 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Fri, 5 Nov 2010 23:22:56 +0000 Subject: [PATCH] Don't check & fetch, just fetch and catch KeyError. git-svn-id: https://svn.erp5.org/repos/neo/trunk@2423 71dcc9de-d417-0410-9af5-da40c76e7ee4 --- neo/client/app.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/neo/client/app.py b/neo/client/app.py index 9cd6b7ad..1e2199d5 100644 --- a/neo/client/app.py +++ b/neo/client/app.py @@ -432,8 +432,12 @@ class Application(object): # Try in cache first self._cache_lock_acquire() try: - if oid in self.mq_cache: - return self.mq_cache[oid][0] + try: + result = self.mq_cache[oid] + except KeyError: + pass + else: + return result[0] finally: self._cache_lock_release() # history return serial, so use it @@ -559,9 +563,12 @@ class Application(object): try: self._cache_lock_acquire() try: - if oid in self.mq_cache: - neo.logging.debug('load oid %s is cached', dump(oid)) + try: serial, data = self.mq_cache[oid] + except KeyError: + pass + else: + neo.logging.debug('load oid %s is cached', dump(oid)) return data, serial finally: self._cache_lock_release() -- 2.30.9