why the celery callback method not invoked ?

11 views
Skip to first unread message

AtticBoy

unread,
Sep 3, 2019, 4:12:23 AM9/3/19
to celery-users
I use celery 4.3.0, here is my code (guosenCelery.py):

@app.task
def add(x, y):
return x + y

@app.task
def on_task_complete(response, uuid):
print("on_task_complete    ", uuid)
result = AsyncResult(uuid)
print("result status:",result.status)
print("result successful:",result.successful())
print("result ready:",result.ready())

app.send_task("guosenCelery.add", args=(1, 2), task_id = '1', link=on_task_complete.s('1'))

the result is :

[2019-09-03 08:03:44,573: INFO/MainProcess] Received task: guosenCelery.add[1]
[2019-09-03 08:03:44,602: INFO/ForkPoolWorker-1] Task guosenCelery.add[1] succeeded in 0.027122433006297797s: 3

and I don't know why the on_task_complete() method is not invoked,  but when I callback the add() method in the same way, 
the add() method is invoked as expected, here is the code and result:

   app.send_task("guosenCelery.add", args=(1, 2), task_id = '1', link=add.s(5))

[2019-09-03 08:08:07,271: INFO/MainProcess] Received task: guosenCelery.add[1]
[2019-09-03 08:08:07,274: INFO/MainProcess] Received task: guosenCelery.add[29b130e9-8690-4d51-a898-e1b967503a2c]
[2019-09-03 08:08:07,275: INFO/ForkPoolWorker-2] Task guosenCelery.add[1] succeeded in 0.003503110958263278s: 3
[2019-09-03 08:08:07,342: INFO/ForkPoolWorker-1] Task guosenCelery.add[29b130e9-8690-4d51-a898-e1b967503a2c] succeeded in 0.06762923195492476s: 8

Looking forwoard for your kind reply, thanks a lot!





AtticBoy

unread,
Sep 3, 2019, 10:13:10 PM9/3/19
to celery-users
I know the reason now, it's the problem of my celery router configuration, thanks.


在 2019年9月3日星期二 UTC+8下午4:12:23,AtticBoy写道:
Reply all
Reply to author
Forward
0 new messages