diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2018-07-19 11:04:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-19 11:04:18 +0100 |
commit | c754e006f4860718057ad6dded91e66f6239bb57 (patch) | |
tree | 6101a439c55c0f6d41c8d13cf5ff985e21fd9d51 /synapse/storage/background_updates.py | |
parent | Move v1-only APIs into their own module & isolate deprecated ones (#3460) (diff) | |
parent | Make Distributor run its processes as a background process (diff) | |
download | synapse-c754e006f4860718057ad6dded91e66f6239bb57.tar.xz |
Merge pull request #3556 from matrix-org/rav/background_processes
Run things as background processes
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.) |