Celery second unregistered task

I have a doubt regarding the implementation of celery with rabbitMQ since only the first function (debug_task()) that I have defined in celery.py is executed.

The problem is that send_user_mail(randomNumber, email) is not working. debug_task is working, so it's registered.

This is the celery console

[2022-10-08 22:28:48,081: ERROR/MainProcess] Received unregistered task of type 'callservices.celery.send_proveedor_mail_new_orden'. The message has been ignored and discarded.

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

Why it's unregistered?

celery.py

from __future__ import absolute_import, unicode_literals
import os

from celery import Celery
from django.conf import settings

from django.core.mail import EmailMultiAlternatives, send_mail


os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'callservices.settings')
app = Celery('tasks',broker='pyamqp://guest@localhost//')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(settings.INSTALLED_APPS)

@app.task()
def debug_task():
    print("hi all")

@app.task()
def send_user_mail(randomNumber, email):
    subject = 'email validation - ServicesYA'
    cuerpo="Your number is: "+str(randomNumber)

    send_mail(subject, cuerpo ,'xxx.ssmtp@xxx.com', [email],fail_silently = False) 
    return 1

This is init.py

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from celery import app as celery_app

__all__ = ('celery_app',)

and in settings.py I add this line:

BROKER_URL = "amqp://guest:guest@localhost:5672//"
Back to Top