summary refs log tree commit diff
path: root/synapse/util/async.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-03-31 10:10:56 +0100
committerGitHub <noreply@github.com>2017-03-31 10:10:56 +0100
commit9cee0ce7dbbf34edc8542b4b02e36ab978da2715 (patch)
tree9832e523b67b8bb43e0bd7bbe2f3ceac233e3e1c /synapse/util/async.py
parentMerge pull request #2076 from matrix-org/erikj/as_perf (diff)
parentRemove unused instance variable (diff)
downloadsynapse-9cee0ce7dbbf34edc8542b4b02e36ab978da2715.tar.xz
Merge pull request #2075 from matrix-org/erikj/cache_speed
Speed up cached function access
Diffstat (limited to 'synapse/util/async.py')
-rw-r--r--synapse/util/async.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/util/async.py b/synapse/util/async.py
index 35380bf8ed..1453faf0ef 100644
--- a/synapse/util/async.py
+++ b/synapse/util/async.py
@@ -89,6 +89,11 @@ class ObservableDeferred(object):
         deferred.addCallbacks(callback, errback)
 
     def observe(self):
+        """Observe the underlying deferred.
+
+        Can return either a deferred if the underlying deferred is still pending
+        (or has failed), or the actual value. Callers may need to use maybeDeferred.
+        """
         if not self._result:
             d = defer.Deferred()
 
@@ -101,7 +106,7 @@ class ObservableDeferred(object):
             return d
         else:
             success, res = self._result
-            return defer.succeed(res) if success else defer.fail(res)
+            return res if success else defer.fail(res)
 
     def observers(self):
         return self._observers