for example, I have this app:
from celery import Celery, Task
class Config:
broker_url = 'pyamqp://guest@192.168.88.82/'
enable_utc = True
task_track_started = True
result_backend = 'rpc://'
include = ['proj.tasks']
app = Celery()
app.config_from_object(Config)
and tasks:
@app.task(bind=True)
def add(self,x,y):
# print(self.request.id)
for i in range(10):
i += 1
sleep(15)
self.update_state(state="PROGRESS", meta={'progress': 10*i})
return (x + y)
then I start the client in python shell to run the task:
from proj import add
r = add.delay(1,1)
r.task_id # get 'bb2b9676-b9ea-4fc0-a45a-75f796217208'
in the same client, I can do the following and get the status and result:
from celery.result import AsyncResult
rid = AsyncResult('bb2b9676-b9ea-4fc0-a45a-75f796217208')
rid.status # get 'PROGRESS' or 'SUCCESS'
in another client (another python shell) I do the same, but I get wrong result:
from celery.result import AsyncResult
rid = AsyncResult('bb2b9676-b9ea-4fc0-a45a-75f796217208')
rid.status # get 'PENDING'
What is happening? I do not understand.