Ver Fonte

Tests passing

Ask Solem há 13 anos atrás
pai
commit
4272feb940

+ 1 - 1
celery/canvas.py

@@ -36,7 +36,7 @@ class _getitem_property(object):
     def __get__(self, obj, type=None):
         if obj is None:
             return type
-        return obj[self.key]
+        return obj.get(self.key)
 
     def __set__(self, obj, value):
         obj[self.key] = value

+ 4 - 4
celery/task/trace.py

@@ -70,7 +70,7 @@ def defines_custom_call(task):
 
 
 class TraceInfo(object):
-    __slots__ = ("state", "retval", "tb")
+    __slots__ = ("state", "retval")
 
     def __init__(self, state, retval=None):
         self.state = state
@@ -205,13 +205,13 @@ def build_tracer(name, task, loader=None, hostname=None, store_errors=True,
                     [subtask(errback).apply_async((uuid, ))
                         for errback in task_request.errbacks or []]
                 else:
-                    task_on_success(retval, uuid, args, kwargs)
+                    if publish_result:
+                        store_result(uuid, retval, SUCCESS)
                     # callback tasks must be applied before the result is
                     # stored, so that result.children is populated.
                     [subtask(callback).apply_async((retval, ))
                         for callback in task_request.callbacks or []]
-                    if publish_result:
-                        store_result(uuid, retval, SUCCESS)
+                    task_on_success(retval, uuid, args, kwargs)
 
                 # -* POST *-
                 if task_request.chord:

+ 0 - 7
celery/tests/tasks/test_trace.py

@@ -78,13 +78,6 @@ class test_TraceInfo(Case):
     class TI(TraceInfo):
         __slots__ = TraceInfo.__slots__ + ("__dict__", )
 
-    def test_without_exc_info(self):
-        x = TraceInfo(states.SUCCESS)
-        self.assertIsNone(x.exc_type)
-        self.assertIsNone(x.exc_value)
-        self.assertIsNone(x.tb)
-        self.assertEqual(x.strtb, '')
-
     def test_handle_error_state(self):
         x = self.TI(states.FAILURE)
         x.handle_failure = Mock()

+ 5 - 4
celery/tests/utilities/test_compat.py

@@ -2,6 +2,7 @@ from __future__ import absolute_import
 
 
 import celery
+from celery.app.task import BaseTask
 from celery.task.base import Task
 
 from celery.tests.utils import Case
@@ -10,11 +11,11 @@ from celery.tests.utils import Case
 class test_MagicModule(Case):
 
     def test_class_property_set_without_type(self):
-        self.assertTrue(Task.__dict__["app"].__get__(Task()))
+        self.assertTrue(BaseTask.__dict__["app"].__get__(Task()))
 
     def test_class_property_set_on_class(self):
-        self.assertIs(Task.__dict__["app"].__set__(None, None),
-                      Task.__dict__["app"])
+        self.assertIs(BaseTask.__dict__["app"].__set__(None, None),
+                      BaseTask.__dict__["app"])
 
     def test_class_property_set(self):
 
@@ -22,7 +23,7 @@ class test_MagicModule(Case):
             pass
 
         app = celery.Celery(set_as_current=False)
-        Task.__dict__["app"].__set__(X(), app)
+        BaseTask.__dict__["app"].__set__(X(), app)
         self.assertEqual(X.app, app)
 
     def test_dir(self):

+ 1 - 1
celery/tests/utilities/test_timer2.py

@@ -59,7 +59,7 @@ class test_Schedule(Case):
         finally:
             timer2.mktime = mktime
 
-        _, exc, _ = scratch[0]
+        exc = scratch[0]
         self.assertIsInstance(exc, OverflowError)
 
 

+ 3 - 5
docs/getting-started/first-steps-with-celery.rst

@@ -142,12 +142,10 @@ AMQP, MongoDB, Tokyo Tyrant and Redis -- or you can define your own.
 For this example we will use the `amqp` result backend, which sends states
 as messages.  The backend is configured via the :setting:`CELERY_RESULT_BACKEND`
 setting or using the ``backend`` argument to :class:`Celery`, in addition individual
-result backends may have additional settings
-you can configure::
+result backends may have additional required or optional settings
+to configure::
 
-    from celery.backends.amqp import AMQPBackend
-
-    celery = Celery(backend=AMQPBackend(expires=300))
+    celery = Celery(backend="amqp")
 
 To read more about result backends please see :ref:`task-result-backends`.
 

+ 16 - 1
examples/app/myapp.py

@@ -18,8 +18,23 @@ You can also specify the app to use with celeryd::
 from celery import Celery
 
 
+def debug_args(fun):
+    from kombu.utils import reprcall
+
+    def _inner(self, *args, **kwargs):
+        print("CALL: %r" % reprcall(self.name, args, kwargs))
+        return fun(*args, **kwargs)
+    return _inner
+
+
+
 celery = Celery("myapp")
-celery.conf.update(BROKER_URL="amqp://guest:guest@localhost:5672//")
+celery.conf.update(
+    BROKER_URL="amqp://guest:guest@localhost:5672//",
+    CELERY_ANNOTATIONS={
+        "myapp.add": {"@__call__": debug_args},
+    },
+)
 
 
 @celery.task