flower
flower copied to clipboard
incorrect task state from /api/task/result/*
I am trying to use the flower's http api to monitor the task state. But it seems that the task state from the "/api/task/result/*" is incorrect (they never seem to be updated). I only tested this in AMQP with rpc backend. On the other hand, values from "/api/tasks" are okay (what is displayed on the web page is also okay).
Here is a simple script that demonstrate the issue.
from celery import Celery
default_broker = 'pyamqp://guest@localhost//'
app = Celery('task_bug', broker=default_broker, backend='rpc://')
api_root = 'http://localhost:5555/api'
url_root = "http://localhost:5555"
@app.task()
def add(x, y):
return x + y
def task_state_from_api_task_result(r):
import requests, json
task_api = '{}/task'.format(api_root)
url = "{}/result/{}".format(task_api, r.task_id)
resp = requests.get(url)
return resp.json()["state"]
if __name__ == '__main__':
r = add.delay(3, 4)
import time
time.sleep(1)
assert r.state == "SUCCESS"
assert task_state_from_api_task_result(r) == "SUCCESS" # This raises an AssertionError
Here is my environment. I have tested flower 0.9.2 and the current master branch.
software -> celery:4.1.0 (latentcall) kombu:4.1.0 py:2.7.14
billiard:3.5.0.3 py-amqp:2.2.2
platform -> system:Linux arch:64bit imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:pyamqp results:rpc:///
broker_url: u'amqp://guest:********@localhost:5672//'
result_backend: u'rpc:///'
I am experiencing this too
Tasks will also remain PENDING when they are complete if ignore_result=True
Happens in both pip version and development version, using Redis broker/backend.