summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-27 14:41:40 +0100
committerErik Johnston <erik@matrix.org>2015-04-27 14:41:40 +0100
commit6f8e2d517e8141f62cb0cfcc73c3842a367ff21c (patch)
tree4f4569d1bbf7b6fcc2a67c1664da38b75e81a5ee /synapse/util
parentShuffle operations so that locking upsert happens last in the txn. This ensur... (diff)
parentMerge pull request #132 from matrix-org/observer_and_locks (diff)
downloadsynapse-6f8e2d517e8141f62cb0cfcc73c3842a367ff21c.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into postgres
Diffstat (limited to 'synapse/util')
-rw-r--r--synapse/util/async.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/util/async.py b/synapse/util/async.py
index c4fe5d522f..d8febdb90c 100644
--- a/synapse/util/async.py
+++ b/synapse/util/async.py
@@ -32,3 +32,22 @@ def run_on_reactor():
     iteration of the main loop
     """
     return sleep(0)
+
+
+def create_observer(deferred):
+    """Creates a deferred that observes the result or failure of the given
+     deferred *without* affecting the given deferred.
+    """
+    d = defer.Deferred()
+
+    def callback(r):
+        d.callback(r)
+        return r
+
+    def errback(f):
+        d.errback(f)
+        return f
+
+    deferred.addCallbacks(callback, errback)
+
+    return d