From e7c72bc235c96dd63abf23a0698f45f79873edf3 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 14 Sep 2009 12:20:33 -0700 Subject: [PATCH] Made the lru cache more robust. --HG-- branch : trunk --- jinja2/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jinja2/utils.py b/jinja2/utils.py index dc52e0b..7e56279 100644 --- a/jinja2/utils.py +++ b/jinja2/utils.py @@ -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() -- 2.26.2