diff options
author | Richard van der Hoff <richard@matrix.org> | 2020-03-31 17:24:06 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2020-03-31 17:24:06 +0100 |
commit | cfe8c8ab8e412b6320e5963ced0670fbc7b00d1b (patch) | |
tree | 22d3eaed314d21069684b9d26cd95cf2e19ed366 | |
parent | Fix "'NoneType' has no attribute start|stop" logcontext errors (#7181) (diff) | |
download | synapse-cfe8c8ab8e412b6320e5963ced0670fbc7b00d1b.tar.xz |
Remove unused `start_background_update`
This was only used in a unit test, so let's just inline it in the test.
-rw-r--r-- | synapse/storage/background_updates.py | 21 | ||||
-rw-r--r-- | tests/storage/test_background_update.py | 14 |
2 files changed, 9 insertions, 26 deletions
diff --git a/synapse/storage/background_updates.py b/synapse/storage/background_updates.py index eb1a7e5002..d4e26eab6c 100644 --- a/synapse/storage/background_updates.py +++ b/synapse/storage/background_updates.py @@ -400,27 +400,6 @@ class BackgroundUpdater(object): self.register_background_update_handler(update_name, updater) - def start_background_update(self, update_name, progress): - """Starts a background update running. - - Args: - update_name: The update to set running. - progress: The initial state of the progress of the update. - - Returns: - A deferred that completes once the task has been added to the - queue. - """ - # Clear the background update queue so that we will pick up the new - # task on the next iteration of do_background_update. - self._background_update_queue = [] - progress_json = json.dumps(progress) - - return self.db.simple_insert( - "background_updates", - {"update_name": update_name, "progress_json": progress_json}, - ) - def _end_background_update(self, update_name): """Removes a completed background update task from the queue. diff --git a/tests/storage/test_background_update.py b/tests/storage/test_background_update.py index ae14fb407d..aca41eb215 100644 --- a/tests/storage/test_background_update.py +++ b/tests/storage/test_background_update.py @@ -25,12 +25,20 @@ class BackgroundUpdateTestCase(unittest.HomeserverTestCase): # the target runtime for each bg update target_background_update_duration_ms = 50000 + store = self.hs.get_datastore() + self.get_success( + store.db.simple_insert( + "background_updates", + values={"update_name": "test_update", "progress_json": '{"my_key": 1}'}, + ) + ) + # first step: make a bit of progress @defer.inlineCallbacks def update(progress, count): yield self.clock.sleep((count * duration_ms) / 1000) progress = {"my_key": progress["my_key"] + 1} - yield self.hs.get_datastore().db.runInteraction( + yield store.db.runInteraction( "update_progress", self.updates._background_update_progress_txn, "test_update", @@ -39,10 +47,6 @@ class BackgroundUpdateTestCase(unittest.HomeserverTestCase): return count self.update_handler.side_effect = update - - self.get_success( - self.updates.start_background_update("test_update", {"my_key": 1}) - ) self.update_handler.reset_mock() res = self.get_success( self.updates.do_next_background_update( |