mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-22 09:35:45 +03:00
Add logging to ObservableDeferred callbacks (#9523)
This commit is contained in:
parent
0764d0c6e5
commit
9898470e7d
2 changed files with 19 additions and 8 deletions
1
changelog.d/9523.misc
Normal file
1
changelog.d/9523.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Add extra logging to ObservableDeferred when callbacks throw exceptions.
|
|
@ -76,11 +76,16 @@ class ObservableDeferred:
|
|||
def callback(r):
|
||||
object.__setattr__(self, "_result", (True, r))
|
||||
while self._observers:
|
||||
observer = self._observers.pop()
|
||||
try:
|
||||
# TODO: Handle errors here.
|
||||
self._observers.pop().callback(r)
|
||||
except Exception:
|
||||
pass
|
||||
observer.callback(r)
|
||||
except Exception as e:
|
||||
logger.exception(
|
||||
"%r threw an exception on .callback(%r), ignoring...",
|
||||
observer,
|
||||
r,
|
||||
exc_info=e,
|
||||
)
|
||||
return r
|
||||
|
||||
def errback(f):
|
||||
|
@ -90,11 +95,16 @@ class ObservableDeferred:
|
|||
# traces when we `await` on one of the observer deferreds.
|
||||
f.value.__failure__ = f
|
||||
|
||||
observer = self._observers.pop()
|
||||
try:
|
||||
# TODO: Handle errors here.
|
||||
self._observers.pop().errback(f)
|
||||
except Exception:
|
||||
pass
|
||||
observer.errback(f)
|
||||
except Exception as e:
|
||||
logger.exception(
|
||||
"%r threw an exception on .errback(%r), ignoring...",
|
||||
observer,
|
||||
f,
|
||||
exc_info=e,
|
||||
)
|
||||
|
||||
if consumeErrors:
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue