summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2017-01-05 13:03:02 +0000
committerMatthew Hodgson <matthew@matrix.org>2017-01-05 13:03:02 +0000
commitb31ed227388d1ec599399184b127ad09de9735dc (patch)
treeb4d71b9d56c0a611165f1bf6b682d5cdb1a7d04c /synapse/util
parentMerge pull request #1744 from matrix-org/matthew/timeout_get_missing_events (diff)
parentMerge pull request #1766 from matrix-org/markjh/linear_logging (diff)
downloadsynapse-b31ed227388d1ec599399184b127ad09de9735dc.tar.xz
Merge branch 'release-v0.18.6' into develop
Diffstat (limited to 'synapse/util')
-rw-r--r--synapse/util/async.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/synapse/util/async.py b/synapse/util/async.py
index 4280455cbe..83875edc85 100644
--- a/synapse/util/async.py
+++ b/synapse/util/async.py
@@ -166,7 +166,11 @@ class Linearizer(object):
             # do some work.
 
     """
-    def __init__(self):
+    def __init__(self, name=None):
+        if name is None:
+            self.name = id(self)
+        else:
+            self.name = name
         self.key_to_defer = {}
 
     @defer.inlineCallbacks
@@ -185,15 +189,20 @@ class Linearizer(object):
         self.key_to_defer[key] = new_defer
 
         if current_defer:
-            logger.info("Waiting to acquire linearizer lock for key %r", key)
+            logger.info(
+                "Waiting to acquire linearizer lock %r for key %r", self.name, key
+            )
             with PreserveLoggingContext():
                 yield current_defer
 
+        logger.info("Acquired linearizer lock %r for key %r", self.name, key)
+
         @contextmanager
         def _ctx_manager():
             try:
                 yield
             finally:
+                logger.info("Releasing linearizer lock %r for key %r", self.name, key)
                 new_defer.callback(None)
                 current_d = self.key_to_defer.get(key)
                 if current_d is new_defer: