summary refs log tree commit diff
path: root/synapse/notifier.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-02 15:26:11 +0100
committerErik Johnston <erik@matrix.org>2014-09-02 15:26:11 +0100
commit464e1fcfa5fbbc51d8b1502df5971cfd2189fd37 (patch)
treef2cf21ddaa6383c7819194cad1df2b5e2d2007be /synapse/notifier.py
parentBF: Prevent controllers from being instantiated twice. (diff)
parentv0.1.2 (diff)
downloadsynapse-464e1fcfa5fbbc51d8b1502df5971cfd2189fd37.tar.xz
Merge branch 'master' of github.com:matrix-org/synapse into release-v0.2.0
Conflicts:
	synapse/notifier.py
	webclient/room/room-controller.js
	webclient/room/room.html
Diffstat (limited to 'synapse/notifier.py')
-rw-r--r--synapse/notifier.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py
index cb544e9886..3260aa744f 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -106,7 +106,9 @@ class Notifier(object):
 
         # TODO (erikj): Can we make this more efficient by hitting the
         # db once?
-        for listener in listeners:
+
+        @defer.inlineCallbacks
+        def notify(listener):
             events, end_key = yield room_source.get_new_events_for_user(
                 listener.user,
                 listener.from_token.room_key,
@@ -122,6 +124,13 @@ class Notifier(object):
                     self, events, listener.from_token, end_token
                 )
 
+        def eb(failure):
+            logger.exception("Failed to notify listener", failure)
+
+        yield defer.DeferredList(
+            [notify(l).addErrback(eb) for l in listeners]
+        )
+
     @defer.inlineCallbacks
     @log_function
     def on_new_user_event(self, users=[], rooms=[]):
@@ -140,7 +149,8 @@ class Notifier(object):
         for room in rooms:
             listeners |= self.rooms_to_listeners.get(room, set()).copy()
 
-        for listener in listeners:
+        @defer.inlineCallbacks
+        def notify(listener):
             events, end_key = yield presence_source.get_new_events_for_user(
                 listener.user,
                 listener.from_token.presence_key,
@@ -156,6 +166,13 @@ class Notifier(object):
                     self, events, listener.from_token, end_token
                 )
 
+        def eb(failure):
+            logger.exception("Failed to notify listener", failure)
+
+        yield defer.DeferredList(
+            [notify(l).addErrback(eb) for l in listeners]
+        )
+
     def get_events_for(self, user, rooms, pagination_config, timeout):
         """ For the given user and rooms, return any new events for them. If
         there are no new events wait for up to `timeout` milliseconds for any