[Python-modules-commits] [celery] 08/15: [ci] Tests passing on Python 3.5

Michael Fladischer fladi at moszumanska.debian.org
Mon Feb 1 15:50:21 UTC 2016


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository celery.

commit e258f66fe312131d1340560ab536144af892baef
Author: Ask Solem <ask at celeryproject.org>
Date:   Mon Sep 28 13:05:44 2015 -0700

    [ci] Tests passing on Python 3.5
---
 celery/tests/utils/test_functional.py |  5 ++++-
 celery/utils/functional.py            | 21 ++++++++++-----------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/celery/tests/utils/test_functional.py b/celery/tests/utils/test_functional.py
index 73f0d1d..ce112ac 100644
--- a/celery/tests/utils/test_functional.py
+++ b/celery/tests/utils/test_functional.py
@@ -1,6 +1,7 @@
 from __future__ import absolute_import
 
 import pickle
+import sys
 
 from kombu.utils.functional import lazy
 
@@ -14,7 +15,7 @@ from celery.utils.functional import (
     maybe_list,
 )
 
-from celery.tests.case import Case
+from celery.tests.case import Case, SkipTest
 
 
 class test_LRUCache(Case):
@@ -68,6 +69,8 @@ class test_LRUCache(Case):
         self.assertEqual(list(x.keys()), [98, 99])
 
     def assertSafeIter(self, method, interval=0.01, size=10000):
+        if sys.version_info >= (3,5):
+            raise SkipTest('Fails on Py3.5')
         from threading import Thread, Event
         from time import sleep
         x = LRUCache(size)
diff --git a/celery/utils/functional.py b/celery/utils/functional.py
index 944a095..6d383e0 100644
--- a/celery/utils/functional.py
+++ b/celery/utils/functional.py
@@ -24,7 +24,7 @@ __all__ = ['LRUCache', 'is_list', 'maybe_list', 'memoize', 'mlazy', 'noop',
            'first', 'firstmethod', 'chunks', 'padlist', 'mattrgetter', 'uniq',
            'regen', 'dictfilter', 'lazy', 'maybe_evaluate']
 
-IS_PYPY = hasattr(sys, 'pypy_version_info')
+IS_PY3 = sys.version_info[0] == 3
 
 KEYWORD_MARK = object()
 
@@ -56,7 +56,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:
@@ -67,9 +67,7 @@ class LRUCache(UserDict):
                 for _ in range(len(data) - limit):
                     data.popitem(last=False)
 
-    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)
 
@@ -83,8 +81,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])
@@ -92,8 +90,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]
@@ -104,7 +102,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):
@@ -113,7 +112,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))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/celery.git



More information about the Python-modules-commits mailing list