This commit is contained in:
Ask Solem 2012-05-11 16:01:54 +01:00
Родитель e3418c22a2
Коммит 4272feb940
7 изменённых файлов: 30 добавлений и 23 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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:

Просмотреть файл

@ -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()

Просмотреть файл

@ -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):

Просмотреть файл

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

Просмотреть файл

@ -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`.

Просмотреть файл

@ -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