mirror of
https://github.com/element-hq/synapse
synced 2024-09-03 22:30:06 +00:00
Improve exception handling in persist_event
1. use `deferred.errback()` instead of `deferred.errback(e)`, which means that a Failure object will be constructed using the current exception state, *including* its stack trace - so the stack trace is saved in the Failure, leading to better exception reports. 2. Set `consumeErrors=True` on the ObservableDeferred, because we know that there will always be at least one observer - which avoids a spurious "CRITICAL: unhandled exception in Deferred" error in the logs
This commit is contained in:
parent
4c65b98e4a
commit
b387ee17b6
1 changed files with 3 additions and 3 deletions
|
@ -110,7 +110,7 @@ class _EventPeristenceQueue(object):
|
||||||
end_item.events_and_contexts.extend(events_and_contexts)
|
end_item.events_and_contexts.extend(events_and_contexts)
|
||||||
return end_item.deferred.observe()
|
return end_item.deferred.observe()
|
||||||
|
|
||||||
deferred = ObservableDeferred(defer.Deferred())
|
deferred = ObservableDeferred(defer.Deferred(), consumeErrors=True)
|
||||||
|
|
||||||
queue.append(self._EventPersistQueueItem(
|
queue.append(self._EventPersistQueueItem(
|
||||||
events_and_contexts=events_and_contexts,
|
events_and_contexts=events_and_contexts,
|
||||||
|
@ -152,8 +152,8 @@ class _EventPeristenceQueue(object):
|
||||||
try:
|
try:
|
||||||
ret = yield per_item_callback(item)
|
ret = yield per_item_callback(item)
|
||||||
item.deferred.callback(ret)
|
item.deferred.callback(ret)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
item.deferred.errback(e)
|
item.deferred.errback()
|
||||||
finally:
|
finally:
|
||||||
queue = self._event_persist_queues.pop(room_id, None)
|
queue = self._event_persist_queues.pop(room_id, None)
|
||||||
if queue:
|
if queue:
|
||||||
|
|
Loading…
Reference in a new issue