From: Armin Ronacher Date: Mon, 14 Sep 2009 19:20:33 +0000 (-0700) Subject: Made the lru cache more robust. X-Git-Tag: 2.2.1~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e7c72bc235c96dd63abf23a0698f45f79873edf3;p=jinja2.git Made the lru cache more robust. --HG-- branch : trunk --- 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()