Celery 4.0.2 AsyncResult.then not working

I would like to accept the promise protocol as shown in the docs . The example given there works, but the promise is processed on the worker side. Instead, I would like to receive a notification on the client.

Here is my test.py:

from celery import Celery

app = Celery(broker='amqp://', backend='rpc')

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

      

On the client side, I enter the following commands:

import test
test.add.delay(2, 2).then(lambda: print('OK'))

      

While googling around I come across this , it is obvious that I am not the only one trying to figure out how it should work.

I understand that once the task has been processed, the result should be sent back to the client and then the callback should fire, but it is not, my promise will never be resolved.

Do I understand correctly? Is this the desired behavior?

thank

+3


source to share


1 answer


Depending on the backend, permission "checking" does not happen automatically. To do this, you need active .ready()

or .wait()

. You can defer this check to a side thread or so.

In the backend, amqp

it will be resolved when trying .ready()

AsyncResult. Then it means pooling for permission. I read somewhere that the redis

backend does a non-merge resolution, but haven't digged its code yet.



I am implementing CeleryExecutor as a ThreadPoolExecutor and had to put .ready()

all the checks in order to invoke the Future permission.

0


source







All Articles