Browse Source

Cosmetics

Ask Solem 13 years ago
parent
commit
eb248135c8
5 changed files with 21 additions and 23 deletions
  1. 8 8
      celery/abstract.py
  2. 6 6
      celery/app/__init__.py
  3. 1 1
      celery/app/amqp.py
  4. 6 6
      celery/app/base.py
  5. 0 2
      funtests/suite/test_basic.py

+ 8 - 8
celery/abstract.py

@@ -27,8 +27,8 @@ class Namespace(object):
     mapping of unclaimed components.  The components will be
     mapping of unclaimed components.  The components will be
     claimed when the namespace they belong to is created.
     claimed when the namespace they belong to is created.
 
 
-    :keyword name:  Set the name of this namespace.
-    :keyword app:  Set the Celery app for this namespace.
+    :keyword name: Set the name of this namespace.
+    :keyword app: Set the Celery app for this namespace.
 
 
     """
     """
     name = None
     name = None
@@ -67,7 +67,7 @@ class Namespace(object):
         self.components = self._claim()
         self.components = self._claim()
         self._debug("Building boot step graph.")
         self._debug("Building boot step graph.")
         self.boot_steps = [self.bind_component(name, parent, **kwargs)
         self.boot_steps = [self.bind_component(name, parent, **kwargs)
-                            for name in self._finalize_boot_steps()]
+                                for name in self._finalize_boot_steps()]
         self._debug("New boot order: %r" % (
         self._debug("New boot order: %r" % (
             [c.name for c in self.boot_steps], ))
             [c.name for c in self.boot_steps], ))
 
 
@@ -75,15 +75,15 @@ class Namespace(object):
             component.include(parent)
             component.include(parent)
         return self
         return self
 
 
-    def import_module(self, module):
-        return import_module(module)
-
     def bind_component(self, name, parent, **kwargs):
     def bind_component(self, name, parent, **kwargs):
         """Bind component to parent object and this namespace."""
         """Bind component to parent object and this namespace."""
         comp = self[name](parent, **kwargs)
         comp = self[name](parent, **kwargs)
         comp.namespace = self
         comp.namespace = self
         return comp
         return comp
 
 
+    def import_module(self, module):
+        return import_module(module)
+
     def __getitem__(self, name):
     def __getitem__(self, name):
         return self.components[name]
         return self.components[name]
 
 
@@ -132,10 +132,10 @@ class ComponentType(type):
 class Component(object):
 class Component(object):
     """A component.
     """A component.
 
 
-    The :meth:`__init__` method called when the component
+    The :meth:`__init__` method is called when the component
     is bound to a parent object, and can as such be used
     is bound to a parent object, and can as such be used
     to initialize attributes in the parent object at
     to initialize attributes in the parent object at
-    parent-instantiaton time.
+    parent instantiation-time.
 
 
     """
     """
     __metaclass__ = ComponentType
     __metaclass__ = ComponentType

+ 6 - 6
celery/app/__init__.py

@@ -29,6 +29,7 @@ _tls.current_app = None
 
 
 
 
 class AppPickler(object):
 class AppPickler(object):
+    """Default application pickler/unpickler."""
 
 
     def __call__(self, cls, *args):
     def __call__(self, cls, *args):
         kwargs = self.build_kwargs(*args)
         kwargs = self.build_kwargs(*args)
@@ -123,15 +124,14 @@ class App(base.BaseApp):
 
 
     def TaskSet(self, *args, **kwargs):
     def TaskSet(self, *args, **kwargs):
         """Create new :class:`~celery.task.sets.TaskSet`."""
         """Create new :class:`~celery.task.sets.TaskSet`."""
-        from ..task.sets import TaskSet
-        kwargs["app"] = self
-        return TaskSet(*args, **kwargs)
+        return instantiate("celery.task.sets:TaskSet",
+                           app=self, *args, **kwargs)
 
 
     def worker_main(self, argv=None):
     def worker_main(self, argv=None):
         """Run :program:`celeryd` using `argv`.  Uses :data:`sys.argv`
         """Run :program:`celeryd` using `argv`.  Uses :data:`sys.argv`
         if `argv` is not specified."""
         if `argv` is not specified."""
-        from ..bin.celeryd import WorkerCommand
-        return WorkerCommand(app=self).execute_from_commandline(argv)
+        return instantiate("celery.bin.celeryd:WorkerCommand", app=self) \
+                    .execute_from_commandline(argv)
 
 
     def task(self, *args, **options):
     def task(self, *args, **options):
         """Decorator to create a task class out of any callable.
         """Decorator to create a task class out of any callable.
@@ -175,7 +175,7 @@ class App(base.BaseApp):
                         "run": staticmethod(fun),
                         "run": staticmethod(fun),
                         "__doc__": fun.__doc__,
                         "__doc__": fun.__doc__,
                         "__module__": fun.__module__}, **options))()
                         "__module__": fun.__module__}, **options))()
-                return registry.tasks[T.name]             # global instance.
+                return registry.tasks[T.name]  # global instance.
 
 
             return _create_task_cls
             return _create_task_cls
 
 

+ 1 - 1
celery/app/amqp.py

@@ -24,7 +24,7 @@ from ..utils import cached_property, textindent, uuid
 #: List of known options to a Kombu producers send method.
 #: List of known options to a Kombu producers send method.
 #: Used to extract the message related options out of any `dict`.
 #: Used to extract the message related options out of any `dict`.
 MSG_OPTIONS = ("mandatory", "priority", "immediate", "routing_key",
 MSG_OPTIONS = ("mandatory", "priority", "immediate", "routing_key",
-                "serializer", "delivery_mode", "compression")
+               "serializer", "delivery_mode", "compression")
 
 
 #: Human readable queue declaration.
 #: Human readable queue declaration.
 QUEUE_FORMAT = """
 QUEUE_FORMAT = """

+ 6 - 6
celery/app/base.py

@@ -28,7 +28,7 @@ from ..utils import cached_property, instantiate, lpmerge
 from .defaults import DEFAULTS, find_deprecated_settings, find
 from .defaults import DEFAULTS, find_deprecated_settings, find
 
 
 import kombu
 import kombu
-if kombu.VERSION < (1, 1, 0):
+if kombu.VERSION < (2, 0):
     raise ImportError("Celery requires Kombu version 1.1.0 or higher.")
     raise ImportError("Celery requires Kombu version 1.1.0 or higher.")
 
 
 BUGREPORT_INFO = """
 BUGREPORT_INFO = """
@@ -305,9 +305,9 @@ class BaseApp(object):
 
 
     def _get_backend(self):
     def _get_backend(self):
         from ..backends import get_backend_cls
         from ..backends import get_backend_cls
-        backend_cls = self.backend_cls or self.conf.CELERY_RESULT_BACKEND
-        backend_cls = get_backend_cls(backend_cls, loader=self.loader)
-        return backend_cls(app=self)
+        return get_backend_cls(
+                    self.backend_cls or self.conf.CELERY_RESULT_BACKEND,
+                    loader=self.loader)(app=self)
 
 
     def _get_config(self):
     def _get_config(self):
         return Settings({}, [self.prepare_config(self.loader.conf),
         return Settings({}, [self.prepare_config(self.loader.conf),
@@ -338,8 +338,8 @@ class BaseApp(object):
                 register_after_fork(self, self._after_fork)
                 register_after_fork(self, self._after_fork)
             except ImportError:
             except ImportError:
                 pass
                 pass
-            limit = self.conf.BROKER_POOL_LIMIT
-            self._pool = self.broker_connection().Pool(limit)
+            self._pool = self.broker_connection().Pool(
+                            limit=self.conf.BROKER_POOL_LIMIT)
         return self._pool
         return self._pool
 
 
     @cached_property
     @cached_property

+ 0 - 2
funtests/suite/test_basic.py

@@ -12,11 +12,9 @@ from celery.tests.utils import unittest
 from celery.tests.functional import tasks
 from celery.tests.functional import tasks
 from celery.tests.functional.case import WorkerCase
 from celery.tests.functional.case import WorkerCase
 
 
-
 from celery.task.control import broadcast
 from celery.task.control import broadcast
 
 
 
 
-
 class test_basic(WorkerCase):
 class test_basic(WorkerCase):
 
 
     def test_started(self):
     def test_started(self):