Browse Source

Another attempt at fixing pypy tests

Ask Solem 10 years ago
parent
commit
43c2e7deab
2 changed files with 7 additions and 1 deletions
  1. 1 1
      celery/tests/utils/test_functional.py
  2. 6 0
      celery/utils/functional.py

+ 1 - 1
celery/tests/utils/test_functional.py

@@ -79,7 +79,7 @@ class test_LRUCache(Case):
             def run(self):
                 while not self.__is_shutdown.isSet():
                     try:
-                        self.cache.data.popitem(last=False)
+                        self.cache.popitem(last=False)
                     except KeyError:
                         break
                 self.__is_stopped.set()

+ 6 - 0
celery/utils/functional.py

@@ -74,6 +74,12 @@ 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)
+        with self.mutex:
+            return self.data.popitem(last)
+
     def __setitem__(self, key, value):
         # remove least recently used key.
         with self.mutex: