summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-09-02 15:26:09 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-09-03 10:40:21 +0100
commit967b45bc1a07ae0e2b3e9522b4857e773deacbd9 (patch)
tree00b8eb6edbe63cd86aa6a01410f2c878ff962a8c /synapse/util
parentNeater is_presence_visible() code (diff)
downloadsynapse-967b45bc1a07ae0e2b3e9522b4857e773deacbd9.tar.xz
Allow optional non-suppression of exceptions through the Distributor
Diffstat (limited to 'synapse/util')
-rw-r--r--synapse/util/distributor.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/synapse/util/distributor.py b/synapse/util/distributor.py
index 9605d7d1b9..9cffaec8f2 100644
--- a/synapse/util/distributor.py
+++ b/synapse/util/distributor.py
@@ -32,7 +32,9 @@ class Distributor(object):
       model will do for today.
     """
 
-    def __init__(self):
+    def __init__(self, suppress_failures=True):
+        self.suppress_failures = suppress_failures
+
         self.signals = {}
         self.pre_registration = {}
 
@@ -40,7 +42,9 @@ class Distributor(object):
         if name in self.signals:
             raise KeyError("%r already has a signal named %s" % (self, name))
 
-        self.signals[name] = Signal(name)
+        self.signals[name] = Signal(name,
+            suppress_failures=self.suppress_failures,
+        )
 
         if name in self.pre_registration:
             signal = self.signals[name]
@@ -74,8 +78,9 @@ class Signal(object):
     method into all of the observers.
     """
 
-    def __init__(self, name):
+    def __init__(self, name, suppress_failures):
         self.name = name
+        self.suppress_failures = suppress_failures
         self.observers = []
 
     def observe(self, observer):
@@ -104,6 +109,10 @@ class Signal(object):
                         failure.type,
                         failure.value,
                         failure.getTracebackObject()))
+                if not self.suppress_failures:
+                    raise failure
             deferreds.append(d.addErrback(eb))
 
-        return defer.DeferredList(deferreds)
+        return defer.DeferredList(
+            deferreds, fireOnOneErrback=not self.suppress_failures
+        )