mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
emails: Improve handling of timeouts when sending.
We use the EMAIL_TIMEOUT django setting to timeout after 15s of trying to send an email. This will nicely lead to retries in the email_senders queue, due to the retry_send_email_failures decorator. smtlib documentation suggests that socket.timeout can be raised as the result of timing out, so in attempts I'm getting smtplib.SMTPServerDisconnected. Either way, seems appropriate to add socket.timeout to the exception that we catch.
This commit is contained in:
committed by
Tim Abbott
parent
294510c68a
commit
d51afcf485
@@ -149,9 +149,10 @@ def retry_send_email_failures(
|
||||
def wrapper(worker: ConcreteQueueWorker, data: Dict[str, Any]) -> None:
|
||||
try:
|
||||
func(worker, data)
|
||||
except (smtplib.SMTPServerDisconnected, socket.gaierror, EmailNotDeliveredException):
|
||||
except (smtplib.SMTPServerDisconnected, socket.gaierror, socket.timeout,
|
||||
EmailNotDeliveredException) as e:
|
||||
def on_failure(event: Dict[str, Any]) -> None:
|
||||
logging.exception("Event %r failed", event)
|
||||
logging.exception("Event %r failed due to exception %s", event, e.__class__.__name__)
|
||||
|
||||
retry_event(worker.queue_name, data, on_failure)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user