Make distributer.fire work as it did

This commit is contained in:
Erik Johnston 2015-05-12 13:14:48 +01:00
parent 95dedb866f
commit 8022b27fc2

View File

@ -15,6 +15,12 @@
from twisted.internet import defer
from synapse.util.logcontext import (
PreserveLoggingContext, preserve_context_over_deferred,
)
from synapse.util import unwrapFirstError
import logging
@ -99,6 +105,7 @@ class Signal(object):
Returns a Deferred that will complete when all the observers have
completed."""
def do(observer):
def eb(failure):
logger.warning(
"%s signal observer %s failed: %r",
@ -108,14 +115,17 @@ class Signal(object):
failure.value,
failure.getTracebackObject()))
if not self.suppress_failures:
failure.raiseException()
return failure
return defer.maybeDeferred(observer, *args, **kwargs).addErrback(eb)
with PreserveLoggingContext():
deferreds = [
defer.maybeDeferred(observer, *args, **kwargs)
do(observer)
for observer in self.observers
]
d = defer.gatherResults(deferreds, consumeErrors=True)
d.addErrback(eb)
return d
d.addErrback(unwrapFirstError)
return preserve_context_over_deferred(d)