Why does celery use a survey with a Redis broker?

According to his documentation on the optioninterval Celery polling for results when using the Redis backend by default using an interval of 0.5 s.

A naive developer might think that any queuing system using Redis would at least try to use their own LIST or PUBSUB mechanisms. Why doesn't celery do this and instead rely on a poll?

As an example, when you call r.get()when working with the celery working tree (which is the default polling interval) for r.get(), exactly 0.5 seconds are executed :

from celery import Celery

app = Celery('tasks', broker='redis://localhost:6379/0',
              backend="redis://localhost:6379/0")

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

if __name__ == "__main__":
    r = add.delay(5, 4)
    result = r.get()
    print(result)
+4
source share
1
+3

Source: https://habr.com/ru/post/1531391/


All Articles