Made the lru cache more robust.
authorArmin Ronacher <armin.ronacher@active-4.com>
Mon, 14 Sep 2009 19:20:33 +0000 (12:20 -0700)
committerArmin Ronacher <armin.ronacher@active-4.com>
Mon, 14 Sep 2009 19:20:33 +0000 (12:20 -0700)
--HG--
branch : trunk

jinja2/utils.py

index dc52e0bcae2ee7a475aeae9006b53cd585339d1f..7e5627954b3f850a38acce5c666f697219dd67c6 100644 (file)
@@ -613,7 +613,7 @@ class LRUCache(object):
         if self._queue[-1] != key:
             try:
                 self._remove(key)
-            except:
+            except ValueError:
                 # if something removed the key from the container
                 # when we read, ignore the ValueError that we would
                 # get otherwise.
@@ -643,7 +643,11 @@ class LRUCache(object):
         self._wlock.acquire()
         try:
             del self._mapping[key]
-            self._remove(key)
+            try:
+                self._remove(key)
+            except ValueError:
+                # __getitem__ is not locked, it might happen
+                pass
         finally:
             self._wlock.release()