Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

emails: Improve handling of timeouts when sending.

Mateusz Manderad51afcf48504
diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py
index a19d14ba2e4..c41fd0870e9 100644
--- a/zerver/worker/queue_processors.py
+++ b/zerver/worker/queue_processors.py
@@ -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)
diff --git a/zproject/computed_settings.py b/zproject/computed_settings.py
index 65c69ef9031..eb4771f5867 100644
--- a/zproject/computed_settings.py
+++ b/zproject/computed_settings.py
@@ -1106,6 +1106,8 @@ elif not EMAIL_HOST:
else:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
+EMAIL_TIMEOUT = 15
+
EMAIL_HOST_PASSWORD = get_secret('email_password')
EMAIL_GATEWAY_PASSWORD = get_secret('email_gateway_password')
AUTH_LDAP_BIND_PASSWORD = get_secret('auth_ldap_bind_password', '')