From 064143c1308cf6354554702d5041ec4bd3ac8ff8 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 27 Aug 2019 14:59:39 +0100 Subject: Use `DeferredLock` instead of `threading.Lock` Signed-off-by: Olivier Wilkinson (reivilibre) --- synapse/handlers/stats.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'synapse/handlers/stats.py') diff --git a/synapse/handlers/stats.py b/synapse/handlers/stats.py index 2f7c108181..8e1bf8b5d5 100644 --- a/synapse/handlers/stats.py +++ b/synapse/handlers/stats.py @@ -66,12 +66,13 @@ class StatsHandler(StateDeltasHandler): @defer.inlineCallbacks def process(): + yield lock.acquire() try: yield self._unsafe_process() finally: - lock.release() + yield lock.release() - if lock.acquire(blocking=False): + if not lock.locked: # we only want to run this process one-at-a-time, # and also, if the initial background updater wants us to keep out, # we should respect that. -- cgit 1.5.1