pmclanahan / django-celery-email

A Django email backend that uses a celery task for sending the email.
BSD 3-Clause "New" or "Revised" License
477 stars 108 forks source link

Retrying returns as Succeeded, even though it should have failed #35

Open dkvdm opened 8 years ago

dkvdm commented 8 years ago

I'm currently on 1.1.4 and when I take down my email server I see this:

worker_1    | [2016-07-31 16:11:13,604: ERROR/Worker-3] email_send[c4bacb03-cc3a-468f-80ec-a4dfc20bf7f4]: Cannot reach CELERY_EMAIL_BACKEND django.core.mail.backends.smtp.EmailBackend
worker_1    | Traceback (most recent call last):
worker_1    |   File "/usr/local/lib/python2.7/dist-packages/djcelery_email/tasks.py", line 48, in send_emails
worker_1    |     conn.open()
worker_1    |   File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 58, in open
worker_1    |     self.connection = connection_class(self.host, self.port, **connection_params)
worker_1    |   File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
worker_1    |     (code, msg) = self.connect(host, port)
worker_1    |   File "/usr/lib/python2.7/smtplib.py", line 316, in connect
worker_1    |     self.sock = self._get_socket(host, port, self.timeout)
worker_1    |   File "/usr/lib/python2.7/smtplib.py", line 291, in _get_socket
worker_1    |     return socket.create_connection((host, port), timeout)
worker_1    |   File "/usr/lib/python2.7/socket.py", line 553, in create_connection
worker_1    |     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
worker_1    | gaierror: [Errno -5] No address associated with hostname
worker_1    | [2016-07-31 16:11:13,610: WARNING/Worker-3] email_send[c4bacb03-cc3a-468f-80ec-a4dfc20bf7f4]: Failed to send email message to [u'test@example.com'], retrying. (gaierror(-5, 'No address associated with hostname'))
worker_1    | [2016-07-31 16:11:13,613: INFO/MainProcess] Received task: email_send[c4bacb03-cc3a-468f-80ec-a4dfc20bf7f4] eta:[2016-07-31 16:12:13.610791-07:00]
worker_1    | [2016-07-31 16:11:13,616: INFO/MainProcess] Task email_send[c4bacb03-cc3a-468f-80ec-a4dfc20bf7f4] succeeded in 0.0200942240008s: 0

The first time it tries to send, it properly returns the error. But when it retries it marks it as succeeded. Even though it continues to be down, it returns with a succeed on the retry. I have confirmed the message actually never gets sent.

dkvdm commented 8 years ago

Related to #19 ?