Y
Y
Yura Khlyan2019-03-21 18:40:09
Django
Yura Khlyan, 2019-03-21 18:40:09

How to properly prepare Django_Q?

Good day. I use Django-Q for tasks. But I can’t do it so that if there is an error, the task would be failed.

task_id = async_task(
            send_email_message, ['[email protected]'],
            'email_templates/user_added_credentials', {},
            task_name='send_invitation_email')

17:23:04 [Q] INFO Process-1:8 processing [send_invitation_email]
ERROR:root:(530, b'Authentication required', '[email protected]')
Traceback (most recent call last):
  File "/home/yskhlyan/auctions_api/portal/users/emails.py", line 19, in send_email_message
    fail_silently=False, html_message=html_msg
  File "/home/yskhlyan/.pyenv/versions/auctions_api_3.7.2/lib/python3.7/site-packages/django/core/mail/__init__.py", line 60, in send_mail
    return mail.send()
  File "/home/yskhlyan/.pyenv/versions/auctions_api_3.7.2/lib/python3.7/site-packages/django/core/mail/message.py", line 294, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/yskhlyan/.pyenv/versions/auctions_api_3.7.2/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 110, in send_messages
    sent = self._send(message)
  File "/home/yskhlyan/.pyenv/versions/auctions_api_3.7.2/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 126, in _send
    self.connection.sendmail(from_email, recipients, message.as_bytes(linesep='\r\n'))
  File "/home/yskhlyan/.pyenv/versions/3.7.2/lib/python3.7/smtplib.py", line 867, in sendmail
    raise SMTPSenderRefused(code, resp, from_addr)
smtplib.SMTPSenderRefused: (530, b'Authentication required', '[email protected]')
17:23:05 [Q] INFO Processed [send_invitation_email]

On the Django admin panel, the task is successful. So it should be, and then you need to somehow manually launch the retray? Or am I doing something wrong?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question