From: Michael Tremer Date: Tue, 24 Oct 2017 14:17:35 +0000 (+0100) Subject: Send each message in one transaction X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81c849b03dc7bc7a01bc2526ef74e214b0518238;p=pbs.git Send each message in one transaction Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/messages.py b/src/buildservice/messages.py index c80612b9..911a1adf 100644 --- a/src/buildservice/messages.py +++ b/src/buildservice/messages.py @@ -41,11 +41,14 @@ class Messages(base.Object): while True: messages = self.get_all(limit=10) - for message in messages: - self.send_msg(message) - else: + # If no emails are available, we end here + if not messages: break + for message in messages: + with self.db.transaction(): + self.send_msg(message) + def send_to_all(self, recipients, subject, body, format=None): """ Sends an email to all recipients and does the translation.