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.

queue_processors: Defer initial email connection creation.

Alex Vandivere6a028427596
diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py
index c6a69957202..e6da895cffc 100644
--- a/zerver/worker/queue_processors.py
+++ b/zerver/worker/queue_processors.py
@@ -790,7 +790,7 @@ class MissedMessageWorker(QueueProcessingWorker):
class EmailSendingWorker(LoopQueueProcessingWorker):
def __init__(self, threaded: bool = False, disable_timeout: bool = False) -> None:
super().__init__(threaded, disable_timeout)
- self.connection: BaseEmailBackend = initialize_connection(None)
+ self.connection: Optional[BaseEmailBackend] = None
@retry_send_email_failures
def send_email(self, event: Dict[str, Any]) -> None:
@@ -812,7 +812,8 @@ class EmailSendingWorker(LoopQueueProcessingWorker):
@override
def stop(self) -> None:
try:
- self.connection.close()
+ if self.connection is not None:
+ self.connection.close()
finally:
super().stop()