skip to Main Content

I am going through the celery tutorial and stepped upon a problem when trying to configure my results backend. I would like to use redis for both results backend and as a broker.

So I started redis with dockers as follows:

docker run -d -p 6379:6379 redis

Then I start my app as:

from celery import Celery

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

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

but upon trying few commands:

>>> res = add.delay(5,5)
>>> res
<AsyncResult: a10b81dd-b27d-47e8-9030-8361a8ce18c9>
>>> res.get(timeout=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/alex/mambaforge/envs/new_env/lib/python3.11/site-packages/celery/result.py", line 247, in get
  File "/Users/alex/mambaforge/envs/new_env/lib/python3.11/site-packages/celery/backends/base.py", line 755, in wait_for_pending
  File "/Users/alex/mambaforge/envs/new_env/lib/python3.11/site-packages/celery/backends/base.py", line 1104, in _is_disabled
NotImplementedError: No result backend is configured.
Please see the documentation for more information.

2

Answers


  1. The app reference you have mentioned is not being used correctly. When you first initiate celery with no backend and broker parameters, it defaults to no backend and rabbitmq broker. And there is a possibility that you have started rabbitmq-server in the background and celery is connecting to that instead of your redis. Check whether any rabbitmq-server process is running and import the app instance correctly.

    Login or Signup to reply.
  2. Maybe I am late, but you tryed to use result_backend enstead backend in your Celery init line ?
    And read about workers: https://docs.celeryq.dev/en/stable/userguide/workers.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search