Add logging to ObservableDeferred callbacks (#9523)

This commit is contained in:
Jonathan de Jong 2021-03-09 12:09:31 +01:00 committed by GitHub
parent 0764d0c6e5
commit 9898470e7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 8 deletions

1
changelog.d/9523.misc Normal file
View File

@ -0,0 +1 @@
Add extra logging to ObservableDeferred when callbacks throw exceptions.

View File

@ -76,11 +76,16 @@ class ObservableDeferred:
def callback(r): def callback(r):
object.__setattr__(self, "_result", (True, r)) object.__setattr__(self, "_result", (True, r))
while self._observers: while self._observers:
observer = self._observers.pop()
try: try:
# TODO: Handle errors here. observer.callback(r)
self._observers.pop().callback(r) except Exception as e:
except Exception: logger.exception(
pass "%r threw an exception on .callback(%r), ignoring...",
observer,
r,
exc_info=e,
)
return r return r
def errback(f): def errback(f):
@ -90,11 +95,16 @@ class ObservableDeferred:
# traces when we `await` on one of the observer deferreds. # traces when we `await` on one of the observer deferreds.
f.value.__failure__ = f f.value.__failure__ = f
observer = self._observers.pop()
try: try:
# TODO: Handle errors here. observer.errback(f)
self._observers.pop().errback(f) except Exception as e:
except Exception: logger.exception(
pass "%r threw an exception on .errback(%r), ignoring...",
observer,
f,
exc_info=e,
)
if consumeErrors: if consumeErrors:
return None return None