summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorRichard van der Hoff <github@rvanderhoff.org.uk>2017-03-20 11:53:36 +0000
committerGitHub <noreply@github.com>2017-03-20 11:53:36 +0000
commiteddce9d74abce0e0e65d5292149933ed9bf6025a (patch)
treeb4db8fbbb01c3ee21724aa5eea4639c01ca23f5e /synapse/storage
parentMerge pull request #2025 from matrix-org/rav/no_reset_state_on_rejections (diff)
parentStop preserve_fn leaking context into the reactor (diff)
downloadsynapse-eddce9d74abce0e0e65d5292149933ed9bf6025a.tar.xz
Merge pull request #2027 from matrix-org/rav/logcontext_leaks
A few fixes to logcontext things
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/background_updates.py15
1 files changed, 3 insertions, 12 deletions
diff --git a/synapse/storage/background_updates.py b/synapse/storage/background_updates.py
index 94b2bcc54a..813ad59e56 100644
--- a/synapse/storage/background_updates.py
+++ b/synapse/storage/background_updates.py
@@ -12,6 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+import synapse.util.async
 
 from ._base import SQLBaseStore
 from . import engines
@@ -84,24 +85,14 @@ class BackgroundUpdateStore(SQLBaseStore):
         self._background_update_performance = {}
         self._background_update_queue = []
         self._background_update_handlers = {}
-        self._background_update_timer = None
 
     @defer.inlineCallbacks
     def start_doing_background_updates(self):
-        assert self._background_update_timer is None, \
-            "background updates already running"
-
         logger.info("Starting background schema updates")
 
         while True:
-            sleep = defer.Deferred()
-            self._background_update_timer = self._clock.call_later(
-                self.BACKGROUND_UPDATE_INTERVAL_MS / 1000., sleep.callback, None
-            )
-            try:
-                yield sleep
-            finally:
-                self._background_update_timer = None
+            yield synapse.util.async.sleep(
+                self.BACKGROUND_UPDATE_INTERVAL_MS / 1000.)
 
             try:
                 result = yield self.do_next_background_update(