summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2019-07-03 09:31:27 +0100
committerGitHub <noreply@github.com>2019-07-03 09:31:27 +0100
commit91753cae5962a56ce0440b06891f1040ba7582e9 (patch)
tree8a2e5f3127b652f5b24ad877c0adb18612175d37 /synapse/handlers
parentRemove SMTP_* env var functionality from docker conf (#5596) (diff)
downloadsynapse-91753cae5962a56ce0440b06891f1040ba7582e9.tar.xz
Fix a number of "Starting txn from sentinel context" warnings (#5605)
Fixes #5602, #5603
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/account_validity.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/handlers/account_validity.py b/synapse/handlers/account_validity.py
index 0719da3ab7..edb48054a0 100644
--- a/synapse/handlers/account_validity.py
+++ b/synapse/handlers/account_validity.py
@@ -22,6 +22,7 @@ from email.mime.text import MIMEText
 from twisted.internet import defer
 
 from synapse.api.errors import StoreError
+from synapse.metrics.background_process_metrics import run_as_background_process
 from synapse.types import UserID
 from synapse.util import stringutils
 from synapse.util.logcontext import make_deferred_yieldable
@@ -67,7 +68,14 @@ class AccountValidityHandler(object):
             )
 
             # Check the renewal emails to send and send them every 30min.
-            self.clock.looping_call(self.send_renewal_emails, 30 * 60 * 1000)
+            def send_emails():
+                # run as a background process to make sure that the database transactions
+                # have a logcontext to report to
+                return run_as_background_process(
+                    "send_renewals", self.send_renewal_emails
+                )
+
+            self.clock.looping_call(send_emails, 30 * 60 * 1000)
 
     @defer.inlineCallbacks
     def send_renewal_emails(self):