summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-08-07 18:13:48 +0100
committerErik Johnston <erik@matrix.org>2015-08-07 18:13:48 +0100
commitffdb8c382860ce2e351614a91c2ce07a91c61455 (patch)
tree5d2b7fd5fc0e70c061258e1903fcc044e2bb05b8
parentCache get_recent_events_for_room (diff)
downloadsynapse-ffdb8c382860ce2e351614a91c2ce07a91c61455.tar.xz
Don't be too enthusiatic with defer.gatherResults
Diffstat (limited to '')
-rw-r--r--synapse/handlers/message.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 765b14d994..11c736f727 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -405,10 +405,14 @@ class MessageHandler(BaseHandler):
             except:
                 logger.exception("Failed to get snapshot")
 
-        yield defer.gatherResults(
-            [handle_room(e) for e in room_list],
-            consumeErrors=True
-        ).addErrback(unwrapFirstError)
+        # Only do N rooms at once
+        n = 5
+        d_list = [handle_room(e) for e in room_list]
+        for ds in [d_list[i:i + n] for i in range(0, len(d_list), n)]:
+            yield defer.gatherResults(
+                ds,
+                consumeErrors=True
+            ).addErrback(unwrapFirstError)
 
         ret = {
             "rooms": rooms_ret,