Skip to content

Commit

Permalink
Tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed May 11, 2012
1 parent e3418c2 commit 4272feb
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion celery/canvas.py
Expand Up @@ -36,7 +36,7 @@ def __init__(self, key):
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
Expand Down
8 changes: 4 additions & 4 deletions celery/task/trace.py
Expand Up @@ -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
Expand Down Expand Up @@ -205,13 +205,13 @@ def trace_task(uuid, args, kwargs, request=None):
[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:
Expand Down
7 changes: 0 additions & 7 deletions celery/tests/tasks/test_trace.py
Expand Up @@ -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()
Expand Down
9 changes: 5 additions & 4 deletions celery/tests/utilities/test_compat.py
Expand Up @@ -2,6 +2,7 @@


import celery
from celery.app.task import BaseTask
from celery.task.base import Task

from celery.tests.utils import Case
Expand All @@ -10,19 +11,19 @@
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):

class X(Task):
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):
Expand Down
2 changes: 1 addition & 1 deletion celery/tests/utilities/test_timer2.py
Expand Up @@ -59,7 +59,7 @@ def on_error(exc_info):
finally:
timer2.mktime = mktime

_, exc, _ = scratch[0]
exc = scratch[0]
self.assertIsInstance(exc, OverflowError)


Expand Down
8 changes: 3 additions & 5 deletions docs/getting-started/first-steps-with-celery.rst
Expand Up @@ -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`.

Expand Down
17 changes: 16 additions & 1 deletion examples/app/myapp.py
Expand Up @@ -18,8 +18,23 @@
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
Expand Down

0 comments on commit 4272feb

Please sign in to comment.