summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2020-03-31 17:31:32 +0100
committerRichard van der Hoff <richard@matrix.org>2020-03-31 17:43:58 +0100
commitb4c22342320d7de86c02dfb36415a38c62bec88d (patch)
tree3ba67bc86f0d45365816167698fa4a86c367d893 /synapse/storage
parentSet a logging context while running the bg updates (diff)
downloadsynapse-b4c22342320d7de86c02dfb36415a38c62bec88d.tar.xz
Make do_next_background_update return a bool
returning a None or an int that we don't use is confusing.
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/background_updates.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/synapse/storage/background_updates.py b/synapse/storage/background_updates.py
index 79494bcdf5..4a59132bf3 100644
--- a/synapse/storage/background_updates.py
+++ b/synapse/storage/background_updates.py
@@ -111,7 +111,7 @@ class BackgroundUpdater(object):
             except Exception:
                 logger.exception("Error doing update")
             else:
-                if result is None:
+                if result:
                     logger.info(
                         "No more background updates to do."
                         " Unscheduling background update task."
@@ -169,9 +169,7 @@ class BackgroundUpdater(object):
 
         return not update_exists
 
-    async def do_next_background_update(
-        self, desired_duration_ms: float
-    ) -> Optional[int]:
+    async def do_next_background_update(self, desired_duration_ms: float) -> bool:
         """Does some amount of work on the next queued background update
 
         Returns once some amount of work is done.
@@ -180,7 +178,7 @@ class BackgroundUpdater(object):
             desired_duration_ms(float): How long we want to spend
                 updating.
         Returns:
-            None if there is no more work to do, otherwise an int
+            True if there is no more work to do, otherwise False
         """
         if not self._background_update_queue:
             updates = await self.db.simple_select_list(
@@ -195,14 +193,14 @@ class BackgroundUpdater(object):
 
         if not self._background_update_queue:
             # no work left to do
-            return None
+            return True
 
         # pop from the front, and add back to the back
         update_name = self._background_update_queue.pop(0)
         self._background_update_queue.append(update_name)
 
         res = await self._do_background_update(update_name, desired_duration_ms)
-        return res
+        return False
 
     async def _do_background_update(
         self, update_name: str, desired_duration_ms: float