summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-04-29 13:31:14 +0100
committerMark Haines <mark.haines@matrix.org>2015-04-29 13:31:14 +0100
commit1319905d7af955e7790eb6072dbf4222674be89e (patch)
tree486b67e4ec4f582d2ccb2702f63f37efd18dcbb4
parentUse bytea rather than BLOB (diff)
downloadsynapse-1319905d7af955e7790eb6072dbf4222674be89e.tar.xz
Use a defer.gatherResults to collect results from the perspective servers
-rw-r--r--synapse/crypto/keyring.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py
index 078361fa85..8709394b97 100644
--- a/synapse/crypto/keyring.py
+++ b/synapse/crypto/keyring.py
@@ -124,18 +124,28 @@ class Keyring(object):
     @defer.inlineCallbacks
     def _get_server_verify_key_impl(self, server_name, key_ids):
         keys = None
+
+        perspective_results = []
         for perspective_name, perspective_keys in self.perspective_servers.items():
-            try:
-                keys = yield self.get_server_verify_key_v2_indirect(
-                    server_name, key_ids, perspective_name, perspective_keys
-                )
-                break
-            except:
-                logging.info(
-                    "Unable to getting key %r for %r from %r",
-                    key_ids, server_name, perspective_name,
-                )
-                pass
+            @defer.inlineCallbacks
+            def get_key():
+                try:
+                    result = yield self.get_server_verify_key_v2_indirect(
+                        server_name, key_ids, perspective_name, perspective_keys
+                    )
+                    defer.returnValue(result)
+                except:
+                    logging.info(
+                        "Unable to getting key %r for %r from %r",
+                        key_ids, server_name, perspective_name,
+                    )
+            perspective_results.append(get_key())
+
+        perspective_results = yield defer.gatherResults(perspective_results)
+
+        for results in perspective_results:
+            if results is not None:
+                keys = results
 
         limiter = yield get_retry_limiter(
             server_name,