Explorar o código

Fixes more eventlet/gevent/threads early patch problems, and also moves importlib+ordereddict (<Py2.7) and simplejson (Py<2.6) dependencies to Kombu

Ask Solem %!s(int64=12) %!d(string=hai) anos
pai
achega
a20ff8a98e

+ 1 - 1
celery/app/amqp.py

@@ -14,10 +14,10 @@ from weakref import WeakValueDictionary
 from kombu import Connection, Consumer, Exchange, Producer, Queue
 from kombu import Connection, Consumer, Exchange, Producer, Queue
 from kombu.common import entry_to_queue
 from kombu.common import entry_to_queue
 from kombu.pools import ProducerPool
 from kombu.pools import ProducerPool
+from kombu.utils import cached_property, uuid
 from kombu.utils.encoding import safe_repr
 from kombu.utils.encoding import safe_repr
 
 
 from celery import signals
 from celery import signals
-from celery.utils import cached_property, uuid
 from celery.utils.text import indent as textindent
 from celery.utils.text import indent as textindent
 
 
 from . import app_or_default
 from . import app_or_default

+ 2 - 1
celery/backends/cache.py

@@ -8,9 +8,10 @@
 """
 """
 from __future__ import absolute_import
 from __future__ import absolute_import
 
 
+from kombu.utils import cached_property
+
 from celery.datastructures import LRUCache
 from celery.datastructures import LRUCache
 from celery.exceptions import ImproperlyConfigured
 from celery.exceptions import ImproperlyConfigured
-from celery.utils import cached_property
 
 
 from .base import KeyValueStoreBackend
 from .base import KeyValueStoreBackend
 
 

+ 1 - 1
celery/backends/redis.py

@@ -8,10 +8,10 @@
 """
 """
 from __future__ import absolute_import
 from __future__ import absolute_import
 
 
+from kombu.utils import cached_property
 from kombu.utils.url import _parse_url
 from kombu.utils.url import _parse_url
 
 
 from celery.exceptions import ImproperlyConfigured
 from celery.exceptions import ImproperlyConfigured
-from celery.utils import cached_property
 
 
 from .base import KeyValueStoreBackend
 from .base import KeyValueStoreBackend
 
 

+ 1 - 2
celery/beat.py

@@ -16,7 +16,7 @@ import sys
 import traceback
 import traceback
 
 
 from billiard import Process, ensure_multiprocessing
 from billiard import Process, ensure_multiprocessing
-from kombu.utils import reprcall
+from kombu.utils import cached_property, reprcall
 from kombu.utils.functional import maybe_promise
 from kombu.utils.functional import maybe_promise
 
 
 from . import __version__
 from . import __version__
@@ -25,7 +25,6 @@ from . import signals
 from . import current_app
 from . import current_app
 from .app import app_or_default
 from .app import app_or_default
 from .schedules import maybe_schedule, crontab
 from .schedules import maybe_schedule, crontab
-from .utils import cached_property
 from .utils.imports import instantiate
 from .utils.imports import instantiate
 from .utils.threads import Event, Thread
 from .utils.threads import Event, Thread
 from .utils.timeutils import humanize_seconds
 from .utils.timeutils import humanize_seconds

+ 1 - 2
celery/canvas.py

@@ -14,11 +14,10 @@ from __future__ import absolute_import
 from operator import itemgetter
 from operator import itemgetter
 from itertools import chain as _chain
 from itertools import chain as _chain
 
 
-from kombu.utils import fxrange, kwdict, reprcall
+from kombu.utils import cached_property, fxrange, kwdict, reprcall, uuid
 
 
 from celery import current_app
 from celery import current_app
 from celery.local import Proxy
 from celery.local import Proxy
-from celery.utils import cached_property, uuid
 from celery.utils.compat import chain_from_iterable
 from celery.utils.compat import chain_from_iterable
 from celery.utils.functional import (
 from celery.utils.functional import (
     maybe_list, is_list, regen,
     maybe_list, is_list, regen,

+ 4 - 1
celery/concurrency/__init__.py

@@ -8,7 +8,10 @@
 """
 """
 from __future__ import absolute_import
 from __future__ import absolute_import
 
 
-from celery.local import symbol_by_name
+# Import from kombu directly as it's used
+# early in the import stage, where celery.utils loads
+# too much (e.g. for eventlet patching)
+from kombu.utils import symbol_by_name
 
 
 ALIASES = {
 ALIASES = {
     'processes': 'celery.concurrency.processes:TaskPool',
     'processes': 'celery.concurrency.processes:TaskPool',

+ 1 - 1
celery/loaders/base.py

@@ -15,11 +15,11 @@ import re
 
 
 from datetime import datetime
 from datetime import datetime
 
 
+from kombu.utils import cached_property
 from kombu.utils.encoding import safe_str
 from kombu.utils.encoding import safe_str
 
 
 from celery.datastructures import DictAttribute
 from celery.datastructures import DictAttribute
 from celery.exceptions import ImproperlyConfigured
 from celery.exceptions import ImproperlyConfigured
-from celery.utils import cached_property
 from celery.utils.imports import import_from_cwd, symbol_by_name
 from celery.utils.imports import import_from_cwd, symbol_by_name
 from celery.utils.functional import maybe_list
 from celery.utils.functional import maybe_list
 
 

+ 3 - 2
celery/result.py

@@ -15,13 +15,14 @@ from collections import deque
 from copy import copy
 from copy import copy
 from itertools import imap
 from itertools import imap
 
 
+from kombu.utils import cached_property
+from kombu.utils.compat import OrderedDict
+
 from . import current_app
 from . import current_app
 from . import states
 from . import states
 from .app import app_or_default
 from .app import app_or_default
 from .datastructures import DependencyGraph
 from .datastructures import DependencyGraph
 from .exceptions import IncompleteStream, TimeoutError
 from .exceptions import IncompleteStream, TimeoutError
-from .utils import cached_property
-from .utils.compat import OrderedDict
 
 
 
 
 def from_serializable(r):
 def from_serializable(r):

+ 2 - 1
celery/tests/backends/test_redis.py

@@ -7,13 +7,14 @@ from mock import Mock, patch
 from nose import SkipTest
 from nose import SkipTest
 from pickle import loads, dumps
 from pickle import loads, dumps
 
 
+from kombu.utils import cached_property, uuid
+
 from celery import current_app
 from celery import current_app
 from celery import states
 from celery import states
 from celery.datastructures import AttributeDict
 from celery.datastructures import AttributeDict
 from celery.exceptions import ImproperlyConfigured
 from celery.exceptions import ImproperlyConfigured
 from celery.result import AsyncResult
 from celery.result import AsyncResult
 from celery.task import subtask
 from celery.task import subtask
-from celery.utils import cached_property, uuid
 from celery.utils.timeutils import timedelta_seconds
 from celery.utils.timeutils import timedelta_seconds
 
 
 from celery.tests.utils import Case
 from celery.tests.utils import Case

+ 2 - 2
celery/tests/utilities/test_datastructures.py

@@ -10,7 +10,7 @@ from celery.datastructures import (
     ConfigurationView,
     ConfigurationView,
     DependencyGraph,
     DependencyGraph,
 )
 )
-from celery.utils.threads import TIMEOUT_MAX
+from celery.utils.compat import THREAD_TIMEOUT_MAX
 from celery.tests.utils import Case, WhateverIO
 from celery.tests.utils import Case, WhateverIO
 
 
 
 
@@ -223,7 +223,7 @@ class test_LRUCache(Case):
             def stop(self):
             def stop(self):
                 self._is_shutdown.set()
                 self._is_shutdown.set()
                 self._is_stopped.wait()
                 self._is_stopped.wait()
-                self.join(TIMEOUT_MAX)
+                self.join(THREAD_TIMEOUT_MAX)
 
 
         burglar = Burglar(x)
         burglar = Burglar(x)
         burglar.start()
         burglar.start()

+ 7 - 3
celery/utils/compat.py

@@ -43,10 +43,14 @@ else:
 
 
 
 
 ############## collections.OrderedDict ######################################
 ############## collections.OrderedDict ######################################
+# was moved to kombu
+from kombu.utils.compat import OrderedDict  # noqa
+
+############## threading.TIMEOUT_MAX #######################################
 try:
 try:
-    from collections import OrderedDict
-except ImportError:                         # pragma: no cover
-    from ordereddict import OrderedDict     # noqa
+    from threading import TIMEOUT_MAX as THREAD_TIMEOUT_MAX
+except ImportError:
+    THREAD_TIMEOUT_MAX = 1e10  # noqa
 
 
 ############## itertools.zip_longest #######################################
 ############## itertools.zip_longest #######################################
 
 

+ 2 - 1
celery/utils/functional.py

@@ -17,8 +17,9 @@ from itertools import islice
 
 
 from kombu.utils import cached_property
 from kombu.utils import cached_property
 from kombu.utils.functional import promise, maybe_promise
 from kombu.utils.functional import promise, maybe_promise
+from kombu.utils.compat import OrderedDict
 
 
-from .compat import UserDict, UserList, OrderedDict
+from .compat import UserDict, UserList
 
 
 KEYWORD_MARK = object()
 KEYWORD_MARK = object()
 is_not_None = partial(operator.is_not, None)
 is_not_None = partial(operator.is_not, None)

+ 1 - 4
celery/utils/imports.py

@@ -16,10 +16,7 @@ import sys
 
 
 from contextlib import contextmanager
 from contextlib import contextmanager
 
 
-# symbol_by_name was moved to local because it's used
-# early in the import stage, where celery.utils loads
-# too much (e.g. for eventlet patching)
-from celery.local import symbol_by_name
+from kombu.utils import symbol_by_name
 
 
 from .compat import reload
 from .compat import reload
 
 

+ 3 - 7
celery/utils/threads.py

@@ -16,19 +16,15 @@ import traceback
 from kombu.syn import _detect_environment
 from kombu.syn import _detect_environment
 
 
 from celery.local import Proxy
 from celery.local import Proxy
+from celery.utils.compat import THREAD_TIMEOUT_MAX
 
 
-USE_PURE_LOCALS = os.environ.get("USE_PURE_LOCALS")
+USE_PURE_LOCALS = os.environ.get('USE_PURE_LOCALS')
 
 
 _Thread = threading.Thread
 _Thread = threading.Thread
 _Event = threading._Event
 _Event = threading._Event
 active_count = (getattr(threading, 'active_count', None) or
 active_count = (getattr(threading, 'active_count', None) or
                 threading.activeCount)
                 threading.activeCount)
 
 
-try:
-    TIMEOUT_MAX = threading.TIMEOUT_MAX
-except AttributeError:
-    TIMEOUT_MAX = 1e10  # noqa
-
 
 
 class Event(_Event):
 class Event(_Event):
 
 
@@ -98,7 +94,7 @@ class bgThread(Thread):
         self._is_shutdown.set()
         self._is_shutdown.set()
         self._is_stopped.wait()
         self._is_stopped.wait()
         if self.is_alive():
         if self.is_alive():
-            self.join(TIMEOUT_MAX)
+            self.join(THREAD_TIMEOUT_MAX)
 
 
 try:
 try:
     from greenlet import getcurrent as get_ident
     from greenlet import getcurrent as get_ident

+ 2 - 2
celery/utils/timer2.py

@@ -20,7 +20,7 @@ from functools import wraps
 from itertools import count
 from itertools import count
 from time import time, sleep, mktime
 from time import time, sleep, mktime
 
 
-from celery.utils.threads import TIMEOUT_MAX
+from celery.utils.compat import THREAD_TIMEOUT_MAX
 from kombu.log import get_logger
 from kombu.log import get_logger
 
 
 VERSION = (1, 0, 0)
 VERSION = (1, 0, 0)
@@ -277,7 +277,7 @@ class Timer(threading.Thread):
         if self.running:
         if self.running:
             self._is_shutdown.set()
             self._is_shutdown.set()
             self._is_stopped.wait()
             self._is_stopped.wait()
-            self.join(TIMEOUT_MAX)
+            self.join(THREAD_TIMEOUT_MAX)
             self.running = False
             self.running = False
 
 
     def ensure_started(self):
     def ensure_started(self):

+ 2 - 1
celery/worker/state.py

@@ -17,9 +17,10 @@ import shelve
 
 
 from collections import defaultdict
 from collections import defaultdict
 
 
+from kombu.utils import cached_property
+
 from celery import __version__
 from celery import __version__
 from celery.datastructures import LimitedSet
 from celery.datastructures import LimitedSet
-from celery.utils import cached_property
 
 
 #: Worker software/platform information.
 #: Worker software/platform information.
 SOFTWARE_INFO = {'sw_ident': 'py-celery',
 SOFTWARE_INFO = {'sw_ident': 'py-celery',

+ 4 - 13
requirements/README.rst

@@ -14,14 +14,6 @@ Index
 
 
     Default requirements for Python 3.2+.
     Default requirements for Python 3.2+.
 
 
-* :file:`requirements/py25.txt`
-
-    Extra requirements needed to run on Python 2.5.
-
-* :file:`requirements/py26.txt`
-
-    Extra requirements needed to run on Python 2.6.
-
 * :file:`requirements/jython.txt`
 * :file:`requirements/jython.txt`
 
 
     Extra requirements needed to run on Jython 2.5
     Extra requirements needed to run on Jython 2.5
@@ -55,12 +47,11 @@ Index
 Examples
 Examples
 ========
 ========
 
 
-Running the tests using Python 2.5
-----------------------------------
+Running the tests
+-----------------
 
 
 ::
 ::
 
 
-    $ pip -E $VIRTUAL_ENV install -U -r requirements/py25.txt
-    $ pip -E $VIRTUAL_ENV install -U -r requirements/default.txt
-    $ pip -E $VIRTUAL_ENV install -U -r requirements/test.txt
+    $ pip install -U -r requirements/default.txt
+    $ pip install -U -r requirements/test.txt
 
 

+ 0 - 3
requirements/py25.txt

@@ -1,3 +0,0 @@
-importlib
-ordereddict
-simplejson

+ 0 - 2
requirements/py26.txt

@@ -1,2 +0,0 @@
-importlib
-ordereddict

+ 0 - 4
setup.py

@@ -149,10 +149,6 @@ install_requires = reqs('default-py3k.txt' if is_py3k else 'default.txt')
 
 
 if is_jython:
 if is_jython:
     install_requires.extend(reqs('jython.txt'))
     install_requires.extend(reqs('jython.txt'))
-if py_version[0:2] == (2, 6):
-    install_requires.extend(reqs('py26.txt'))
-elif py_version[0:2] == (2, 5):
-    install_requires.extend(reqs('py25.txt'))
 
 
 # -*- Tests Requires -*-
 # -*- Tests Requires -*-
 
 

+ 0 - 2
tox.ini

@@ -49,7 +49,6 @@ commands = {toxinidir}/extra/release/removepyc.sh {toxinidir}
 [testenv:py26]
 [testenv:py26]
 basepython = python2.6
 basepython = python2.6
 deps = -r{toxinidir}/requirements/default.txt
 deps = -r{toxinidir}/requirements/default.txt
-       -r{toxinidir}/requirements/py26.txt
        -r{toxinidir}/requirements/test.txt
        -r{toxinidir}/requirements/test.txt
        -r{toxinidir}/requirements/test-ci.txt
        -r{toxinidir}/requirements/test-ci.txt
 commands = {toxinidir}/extra/release/removepyc.sh {toxinidir}
 commands = {toxinidir}/extra/release/removepyc.sh {toxinidir}
@@ -62,7 +61,6 @@ commands = {toxinidir}/extra/release/removepyc.sh {toxinidir}
 [testenv:py25]
 [testenv:py25]
 basepython = python2.5
 basepython = python2.5
 deps = -r{toxinidir}/requirements/default.txt
 deps = -r{toxinidir}/requirements/default.txt
-       -r{toxinidir}/requirements/py25.txt
        -r{toxinidir}/requirements/test.txt
        -r{toxinidir}/requirements/test.txt
        -r{toxinidir}/requirements/test-ci.txt
        -r{toxinidir}/requirements/test-ci.txt
 commands = {toxinidir}/extra/release/removepyc.sh {toxinidir}
 commands = {toxinidir}/extra/release/removepyc.sh {toxinidir}