Answer the question
In order to leave comments, you need to log in
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'
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()
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)
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)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question