summary refs log tree commit diff
path: root/synapse/util/async.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-04-27 18:29:32 +0100
committerMark Haines <mark.haines@matrix.org>2015-04-27 18:29:32 +0100
commitf8b865264a02e263d9b37ac3d9d8bea2e874ed55 (patch)
treeadc8b964febfad000b5cd1caa19c2a5793a709f8 /synapse/util/async.py
parentAdd config for setting the perspective servers (diff)
parentMerge pull request #132 from matrix-org/observer_and_locks (diff)
downloadsynapse-f8b865264a02e263d9b37ac3d9d8bea2e874ed55.tar.xz
Merge branch 'develop' into key_distribution
Conflicts:
	synapse/crypto/keyring.py
Diffstat (limited to 'synapse/util/async.py')
-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