Make distributer.fire work as it did
This commit is contained in:
parent
95dedb866f
commit
8022b27fc2
|
@ -15,6 +15,12 @@
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
|
from synapse.util.logcontext import (
|
||||||
|
PreserveLoggingContext, preserve_context_over_deferred,
|
||||||
|
)
|
||||||
|
|
||||||
|
from synapse.util import unwrapFirstError
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,23 +105,27 @@ class Signal(object):
|
||||||
Returns a Deferred that will complete when all the observers have
|
Returns a Deferred that will complete when all the observers have
|
||||||
completed."""
|
completed."""
|
||||||
|
|
||||||
def eb(failure):
|
def do(observer):
|
||||||
logger.warning(
|
def eb(failure):
|
||||||
"%s signal observer %s failed: %r",
|
logger.warning(
|
||||||
self.name, observer, failure,
|
"%s signal observer %s failed: %r",
|
||||||
exc_info=(
|
self.name, observer, failure,
|
||||||
failure.type,
|
exc_info=(
|
||||||
failure.value,
|
failure.type,
|
||||||
failure.getTracebackObject()))
|
failure.value,
|
||||||
if not self.suppress_failures:
|
failure.getTracebackObject()))
|
||||||
failure.raiseException()
|
if not self.suppress_failures:
|
||||||
|
return failure
|
||||||
|
return defer.maybeDeferred(observer, *args, **kwargs).addErrback(eb)
|
||||||
|
|
||||||
deferreds = [
|
with PreserveLoggingContext():
|
||||||
defer.maybeDeferred(observer, *args, **kwargs)
|
deferreds = [
|
||||||
for observer in self.observers
|
do(observer)
|
||||||
]
|
for observer in self.observers
|
||||||
|
]
|
||||||
|
|
||||||
d = defer.gatherResults(deferreds, consumeErrors=True)
|
d = defer.gatherResults(deferreds, consumeErrors=True)
|
||||||
d.addErrback(eb)
|
|
||||||
|
|
||||||
return d
|
d.addErrback(unwrapFirstError)
|
||||||
|
|
||||||
|
return preserve_context_over_deferred(d)
|
||||||
|
|
Loading…
Reference in New Issue