diff options
author | Erik Johnston <erik@matrix.org> | 2015-08-07 19:28:05 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-08-07 19:28:05 +0100 |
commit | 06218ab12599cedf19cfbf26813513c570220f7e (patch) | |
tree | 045e241c7c8a8a33ed55f93f1d383d48d0eaac9f /synapse/util/async.py | |
parent | Merge pull request #213 from matrix-org/paul/SYN-420 (diff) | |
parent | s/observed/observer/ (diff) | |
download | synapse-06218ab12599cedf19cfbf26813513c570220f7e.tar.xz |
Merge pull request #212 from matrix-org/erikj/cache_deferreds
Make CacheDescriptor cache deferreds rather than the deferreds' values
Diffstat (limited to 'synapse/util/async.py')
-rw-r--r-- | synapse/util/async.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/synapse/util/async.py b/synapse/util/async.py index 5a1d545c96..7bf2d38bb8 100644 --- a/synapse/util/async.py +++ b/synapse/util/async.py @@ -51,7 +51,7 @@ class ObservableDeferred(object): object.__setattr__(self, "_observers", set()) def callback(r): - self._result = (True, r) + object.__setattr__(self, "_result", (True, r)) while self._observers: try: self._observers.pop().callback(r) @@ -60,7 +60,7 @@ class ObservableDeferred(object): return r def errback(f): - self._result = (False, f) + object.__setattr__(self, "_result", (False, f)) while self._observers: try: self._observers.pop().errback(f) @@ -97,3 +97,8 @@ class ObservableDeferred(object): def __setattr__(self, name, value): setattr(self._deferred, name, value) + + def __repr__(self): + return "<ObservableDeferred object at %s, result=%r, _deferred=%r>" % ( + id(self), self._result, self._deferred, + ) |