summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-15 14:17:16 +0100
committerErik Johnston <erik@matrix.org>2015-04-15 14:17:16 +0100
commit1ec6fa98c93114f1799a26100a970273e97576bb (patch)
tree1dbc055748fc89978835c02ec8a61f35ae417e30 /synapse
parentTurn off persistance of sent_transactions.response_json (diff)
downloadsynapse-1ec6fa98c93114f1799a26100a970273e97576bb.tar.xz
Parellelize initial sync
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/message.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 7b9685be7f..9c2ef94290 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -274,7 +274,8 @@ class MessageHandler(BaseHandler):
         if limit is None:
             limit = 10
 
-        for event in room_list:
+        @defer.inlineCallbacks
+        def handle_room(event):
             d = {
                 "room_id": event.room_id,
                 "membership": event.membership,
@@ -290,7 +291,7 @@ class MessageHandler(BaseHandler):
             rooms_ret.append(d)
 
             if event.membership != Membership.JOIN:
-                continue
+                return
             try:
                 messages, token = yield self.store.get_recent_events_for_room(
                     event.room_id,
@@ -321,6 +322,11 @@ class MessageHandler(BaseHandler):
             except:
                 logger.exception("Failed to get snapshot")
 
+        yield defer.gatherResults(
+            [handle_room(e) for e in room_list],
+            consumeErrors=True
+        )
+
         ret = {
             "rooms": rooms_ret,
             "presence": presence,