diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-07-18 14:35:24 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-07-18 20:55:05 +0100 |
commit | 667fba68f3ca808f48143a2a739a54665b0162c6 (patch) | |
tree | bc180067772796f815877cfa5aefcd0a471fab9e /synapse/storage/background_updates.py | |
parent | Merge pull request #3553 from matrix-org/rav/background_process_tracking (diff) | |
download | synapse-667fba68f3ca808f48143a2a739a54665b0162c6.tar.xz |
Run things as background processes
This fixes #3518, and ensures that we get useful logs and metrics for lots of things that happen in the background. (There are certainly more things that happen in the background; these are just the common ones I've found running a single-process synapse locally).
Diffstat (limited to 'synapse/storage/background_updates.py')
-rw-r--r-- | synapse/storage/background_updates.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/storage/background_updates.py b/synapse/storage/background_updates.py index dc9eca7d15..5fe1ca2de7 100644 --- a/synapse/storage/background_updates.py +++ b/synapse/storage/background_updates.py @@ -19,6 +19,8 @@ from canonicaljson import json from twisted.internet import defer +from synapse.metrics.background_process_metrics import run_as_background_process + from . import engines from ._base import SQLBaseStore @@ -87,10 +89,14 @@ class BackgroundUpdateStore(SQLBaseStore): self._background_update_handlers = {} self._all_done = False - @defer.inlineCallbacks def start_doing_background_updates(self): - logger.info("Starting background schema updates") + run_as_background_process( + "background_updates", self._run_background_updates, + ) + @defer.inlineCallbacks + def _run_background_updates(self): + logger.info("Starting background schema updates") while True: yield self.hs.get_clock().sleep( self.BACKGROUND_UPDATE_INTERVAL_MS / 1000.) |