Cannot get State & Result Of Remote Celery Worker

576 Views Asked by At

My Architecture:

  • master-machine:

    RabbitMQ 3.6.5 (broker)

    Redis (backend)

    Flower

    Celery default worker

    Webserver application

  • slave-machine1:

    Celery default worker

  • slave-machine2:

    Celery default worker

I'm triggering tasks via Webserver application (from master-machine), for example: task_id = task1.delay(1,2,3).id.

I have an API for retrieving the task status / result (again, from master-machine):

result = task1.AsyncResult(task_id, app=celery_app)
    if result.ready():
        return result.get()

    return result.state 

where celery_app defined exactly as in workers.. (broker, backend..)

The Problem: when consumed by default worker of the master-machine it is possible to retrieve the state / result of the task, but when consumed by slave-machines workers I can't seem to retrieve the correct state /result: (result.state ==PENDING forever).

From Flower which is on the master-machine I can retrieve the correct state / result (SUCCESS + actual result).

In addition, the result appears in Redis backend as SUCCESS:

redis-cli -h master-machine -p 6379 
127.0.0.1:6379> get "celery-task-meta-74de04de-0d4e-45bc-977d-16caab047eed"
    "{\"status\": \"SUCCESS\", \"traceback\": null, \"result\": {123}, \"task_id\": \"74de04de-0d4e-45bc-977d-16caab047eed\", \"children\": []}"

Any idea why this happens? I would like to be able to retrieve tasks' state / result including the tasks that run on the slaves-machines.

0

There are 0 best solutions below