When I try to use the example in Celery
documentation which is add
method with subtask
, I can't get final result.
@task
def add(x, y, callback=None):
result = x + y
if callback:
subtask(callback).delay(result)
return result
When I call the task with;
>>> subadd = add.subtask(args=(5, ))
>>> r=add.apply_async(args=(1, 2,subadd))
>>> r.result
3
As it is seen, it returns 3
instead of 8
.
There is an ERROR on a worker when I run these part. I don't know why it is happenning.
[2013-06-27 07:49:18,080: ERROR/MainProcess] Received unregistered task of type 'devicemanagement.celery_task.add'.
What should I do to get 8 from result?
Thank You!
Should it not be the following:
r = add.apply_async((1, 2), link=add.s(5))
r.result