瀏覽代碼

Another attempt at fixing pypy tests

Ask Solem 10 年之前
父節點
當前提交
d62629f1a1
共有 2 個文件被更改,包括 7 次插入1 次删除
  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

@@ -68,6 +68,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: