diff options
author | Erik Johnston <erikj@jki.re> | 2017-03-31 10:10:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-31 10:10:56 +0100 |
commit | 9cee0ce7dbbf34edc8542b4b02e36ab978da2715 (patch) | |
tree | 9832e523b67b8bb43e0bd7bbe2f3ceac233e3e1c /synapse/util/async.py | |
parent | Merge pull request #2076 from matrix-org/erikj/as_perf (diff) | |
parent | Remove unused instance variable (diff) | |
download | synapse-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.py | 7 |
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 |