I am using celery with redis.
Current redis is used as broker and as result backend.
BROKER_TRANSPORT = 'redis'
BROKER_URL = 'redis://domain:8888/0'
CELERY_RESULT_BACKEND = 'redis://domain:8888/0'
I want to clear few things
The question is already answered. So, I would like to show the snapshots of what celery stores in DB just to give an idea.
Here, I have used the default settings of celery with MySQL database as result_backend
.
It has created two tables:
1. celery_taskmeta
and
2. celery_tasksetmeta
A result backend is exactly what it sounds like, all it does is store results from tasks.
Let's say that you have the following task that actually returns a value.
@task
def sum(x, y):
return x + y
At some point, you call this task. If you do not have a result backend, get() will throw an error (or a warning, I forget which). If you do have a result backend (and assuming it's properly configured), task.get()
will poll your redis-backend for a result from the task_id
associated with task
and then return it to you via whatever serializer you specified.
from tasks import sum
task = sum.delay(3, 4)
task.get()
You can see that it works by just calling get()
(and waiting to completion) on a task that you've sent off to the broker. You can read more about working with celery results from the official documentation.
You can in principle poll your redis database from the redis-cli, but I see no reason to. You can view results in flower by going to one of the actual task detail views and checking the "result" field under the "Basic Task Options" table. e.g. http://flower.myserver.com/task/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With