M
M
max32772019-05-07 18:44:59
Django
max3277, 2019-05-07 18:44:59

Why does an error occur when executing a task in Celery (django)?

Django + Celery + redis
Two errors occur
when starting Celery

[2019-05-07 18:22:53,012: WARNING/MainProcess] /home/django/venv/lib/python3.5/site-packages/celery/app/control.py:54: DuplicateNodenameWarning: Received multiple replies from node name: [email protected]
Please make sure you give each node a unique nodename using
the celery worker `-n` option.
pluralize(len(dupes), 'name'), ', '.join(sorted(dupes)),

Second:
Performing a simple task via
python ./manage.py shell
>>> asd.delay()
<AsyncResult: 4df07451-f474-405b-92e2-6b604191998c>

But there is an error in the celery logs
[2019-05-07 18:22:57,733: ERROR/MainProcess] Received unregistered task of type 'bot.tasks.asd'.
The message has been ignored and discarded.
Did you remember to import the module containing this task?
Or maybe you're using relative imports?
Please see
docs.celeryq.org/en/latest/internals/protocol.html
for more information.
The full contents of the message body was:
b'[[], {}, {"errbacks": null, "callbacks": null, "chain": null, "chord": null}]' (77b)
Traceback ( most recent call last):
File "/home/django/venv/lib/python3.5/site-packages/celery/worker/consumer/consumer.py", line 559,

Sometimes it is executed 1 time out of several, then again an error
[2019-05-07 18:43:26,645: INFO/ForkPoolWorker-1] Task bot.tasks.asd[f6c131b4-dea7-4b67-a49c-bd7adb0158bc] succeeded in 0.0036388610024005175s: 100

code in tasks.py
from __future__ import absolute_import, unicode_literals
from celery import task


@task
def asd():
    return (100)
    # Some other code

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FulTupFul, 2019-05-07
@max3277

app = Celery('app', broker='redis://localhost:6379/1',
             backend='redis://localhost:6379/1', include=['app.tasks'])

You may have configured incorrectly. When specifying a broker and a backend, you must use non-intersecting databases. It is better to specify the full configuration

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question