diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2020-03-16 15:36:57 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2020-03-16 15:36:57 +0000 |
commit | bf117c452a5d9be0515cbc955dce50bd9587b8c7 (patch) | |
tree | 3ff5f1ff415be7b893b29514c160731cb7abe2d2 /synapse/util | |
parent | Modify doc to update Google ReCaptcha terms (#6257) (diff) | |
parent | Merge pull request #6291 from matrix-org/erikj/fix_cache_descriptor (diff) | |
download | synapse-bf117c452a5d9be0515cbc955dce50bd9587b8c7.tar.xz |
Merge pull request #6291 from matrix-org/erikj/fix_cache_descriptor
Diffstat (limited to 'synapse/util')
-rw-r--r-- | synapse/util/async_helpers.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/synapse/util/async_helpers.py b/synapse/util/async_helpers.py index 7659eaeb42..b60a604474 100644 --- a/synapse/util/async_helpers.py +++ b/synapse/util/async_helpers.py @@ -86,11 +86,12 @@ class ObservableDeferred(object): deferred.addCallbacks(callback, errback) - def observe(self): + def observe(self) -> defer.Deferred: """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. + This returns a brand new deferred that is resolved when the underlying + deferred is resolved. Interacting with the returned deferred does not + effect the underdlying deferred. """ if not self._result: d = defer.Deferred() @@ -105,7 +106,7 @@ class ObservableDeferred(object): return d else: success, res = self._result - return res if success else defer.fail(res) + return defer.succeed(res) if success else defer.fail(res) def observers(self): return self._observers |