|  | @@ -25,7 +25,7 @@ __all__ = ['LRUCache', 'is_list', 'maybe_list', 'memoize', 'mlazy', 'noop',
 | 
	
		
			
				|  |  |             'first', 'firstmethod', 'chunks', 'padlist', 'mattrgetter', 'uniq',
 | 
	
		
			
				|  |  |             'regen', 'dictfilter', 'lazy', 'maybe_evaluate', 'head_from_fun']
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -IS_PYPY = hasattr(sys, 'pypy_version_info')
 | 
	
		
			
				|  |  | +IS_PY3 = sys.version_info[0] == 3
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  KEYWORD_MARK = object()
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -62,7 +62,7 @@ class LRUCache(UserDict):
 | 
	
		
			
				|  |  |      def __getitem__(self, key):
 | 
	
		
			
				|  |  |          with self.mutex:
 | 
	
		
			
				|  |  |              value = self[key] = self.data.pop(key)
 | 
	
		
			
				|  |  | -        return value
 | 
	
		
			
				|  |  | +            return value
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def update(self, *args, **kwargs):
 | 
	
		
			
				|  |  |          with self.mutex:
 | 
	
	
		
			
				|  | @@ -74,9 +74,7 @@ class LRUCache(UserDict):
 | 
	
		
			
				|  |  |                  for item in islice(iter(data), len(data) - limit):
 | 
	
		
			
				|  |  |                      data.pop(item)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    def popitem(self, last=True, _needs_lock=IS_PYPY):
 | 
	
		
			
				|  |  | -        if not _needs_lock:
 | 
	
		
			
				|  |  | -            return self.data.popitem(last)
 | 
	
		
			
				|  |  | +    def popitem(self, last=True):
 | 
	
		
			
				|  |  |          with self.mutex:
 | 
	
		
			
				|  |  |              return self.data.popitem(last)
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -90,8 +88,8 @@ class LRUCache(UserDict):
 | 
	
		
			
				|  |  |      def __iter__(self):
 | 
	
		
			
				|  |  |          return iter(self.data)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    def _iterate_items(self, _need_lock=IS_PYPY):
 | 
	
		
			
				|  |  | -        with self.mutex if _need_lock else DummyContext():
 | 
	
		
			
				|  |  | +    def _iterate_items(self):
 | 
	
		
			
				|  |  | +        with self.mutex:
 | 
	
		
			
				|  |  |              for k in self:
 | 
	
		
			
				|  |  |                  try:
 | 
	
		
			
				|  |  |                      yield (k, self.data[k])
 | 
	
	
		
			
				|  | @@ -99,8 +97,8 @@ class LRUCache(UserDict):
 | 
	
		
			
				|  |  |                      pass
 | 
	
		
			
				|  |  |      iteritems = _iterate_items
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    def _iterate_values(self, _need_lock=IS_PYPY):
 | 
	
		
			
				|  |  | -        with self.mutex if _need_lock else DummyContext():
 | 
	
		
			
				|  |  | +    def _iterate_values(self):
 | 
	
		
			
				|  |  | +        with self.mutex:
 | 
	
		
			
				|  |  |              for k in self:
 | 
	
		
			
				|  |  |                  try:
 | 
	
		
			
				|  |  |                      yield self.data[k]
 | 
	
	
		
			
				|  | @@ -111,7 +109,8 @@ class LRUCache(UserDict):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def _iterate_keys(self):
 | 
	
		
			
				|  |  |          # userdict.keys in py3k calls __getitem__
 | 
	
		
			
				|  |  | -        return keys(self.data)
 | 
	
		
			
				|  |  | +        with self.mutex:
 | 
	
		
			
				|  |  | +            return keys(self.data)
 | 
	
		
			
				|  |  |      iterkeys = _iterate_keys
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def incr(self, key, delta=1):
 | 
	
	
		
			
				|  | @@ -120,7 +119,7 @@ class LRUCache(UserDict):
 | 
	
		
			
				|  |  |              # integer as long as it exists and we can cast it
 | 
	
		
			
				|  |  |              newval = int(self.data.pop(key)) + delta
 | 
	
		
			
				|  |  |              self[key] = str(newval)
 | 
	
		
			
				|  |  | -        return newval
 | 
	
		
			
				|  |  | +            return newval
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def __getstate__(self):
 | 
	
		
			
				|  |  |          d = dict(vars(self))
 |