celery не видит задачу

main.py

from celery import Celery


app = Celery('first_step', backend='rpc://', broker='redis://localhost')

app.conf.broker_url = 'redis://localhost:6379/0'


@app.task

def summary(x, y):

    return x + y

test1.py

from first_step import summary


res = summary.delay(4, 4)

print(res.get(timeout=1))

При попытке запустить код в терминале worker отдает

> Traceback (most recent call last):
  File "D:\Mivla\venv\lib\site-packages\celery\worker\consumer\consumer.py", line 591, in on_task_received
    strategy = strategies[type_]
KeyError: 'celerist.main.summary'
[2023-04-06 23:49:45,903: ERROR/MainProcess] Received unregistered task of type 'celerist.main.summary'.
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you're using relative imports?

Ответы (0 шт):