got a bit stuck solving a problem of asynchronic email sending. I'd like to use celery, and django database as a backend. since for now the only thing I'd like to use this queue managing tool for is email, I've installed django-celery-email as well.
Following the instruction, I've made such updates to my settings file:
INSTALLED_APPS += ('kombu.transport.django',
BROKER_URL = 'django://'
EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'email@example.com'
EMAIL_HOST_PASSWORD = '*********'
EMAIL_PORT = 587
>>> from django.core.mail import send_mail
>>> from django.conf import settings
>>> result = send_mail('test send', 'test_send_body_text', settings.EMAIL_HOST_USER, 'firstname.lastname@example.org')
try opening a shell, try sending an email with djcelery email backend and inspect the
It should be a standard celery
AsyncResult that gives you more info on what is happening.
to quote from the docs
results will be a list of celery AsyncResult objects that you may ignore, or use to check the status of the email delivery task, or even wait for it to complete if want. You have to enable a result backend and set ignore_result to False in CELERY_EMAIL_TASK_CONFIG if you want to use these. See the Celery docs for more info.
usually the PENDING state is for tasks that are waiting the execution or not known.
Task is waiting for execution or unknown. Any task id that is not known is implied to be in the pending state.
double check you have started your workers:
./manage.py celeryd -B
usually if celery can't send the task to the backend it throws an error, but the task remains pending until a worker acks it.