R
R
reqww2020-08-16 14:31:54
Django
reqww, 2020-08-16 14:31:54

Spawning an infinite number of CELERY workers?

Trying to perform a primitive task of sending an email using CELERY
Everything seems to be fine, but for some reason, instead of performing tasks, CELERY is spawning workers celery
settings:

REDIS_HOST = '0.0.0.0'
REDIS_PORT = '6379'
CELERY_BROKER_URL = f'redis://{REDIS_HOST}:{REDIS_PORT}/0'
CELERY_BROKER_TRANSPORT_OPTIONS = {'visiblity_timeout': 3600}
CELERY_RESULT_BACKEND = f'redis://{REDIS_HOST}:{REDIS_PORT}/0'
CELERY_ACCEPT_CONTENT = ['json', 'applicaion/json', 'applicaion/text']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERILIZER = 'json'


celery.py:
import os
from celery import Celery
# from celery.schedules import crontab

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'send_email.settings')

app = Celery('send_email')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()


tasks.py:
from send_email.celery import app as celery_app

from .service import send

@celery_app.task
def send_spam_email(user_email):
    send(user_email)


views.py
class ContactView(CreateView):
    '''Отображение формы подписки на email'''
    model = Contact
    form_class = ContactForm
    success_url = '/'
    template_name = 'main/contact.html'

    def form_valid(self, form):
        form.save()
        #send(form.instance.email)
        send_spam_email.delay(form.instance.email)
        return super().form_valid(form)


I run the following command:
celery -A send_email worker -l info -c 4
I also use redis from the docker container I checked
the code itself for operability without celery (smtp works)

spawns workers, so the console looks like this:
5f3918e71371e128186670.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
reqww, 2020-08-16
@reqww

celery -A your_app_name worker --pool=solo -l info

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question