Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add logging to ObservableDeferred callbacks (#9523)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowJonathan authored Mar 9, 2021
1 parent 0764d0c commit 9898470
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/9523.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add extra logging to ObservableDeferred when callbacks throw exceptions.
26 changes: 18 additions & 8 deletions synapse/util/async_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,16 @@ def __init__(self, deferred: defer.Deferred, consumeErrors: bool = False):
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):
Expand All @@ -90,11 +95,16 @@ def errback(f):
# 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
Expand Down

0 comments on commit 9898470

Please sign in to comment.