summary refs log tree commit diff
path: root/synapse/federation/federation_client.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-02-18 10:34:40 +0000
committerErik Johnston <erik@matrix.org>2015-02-18 10:34:40 +0000
commit1be67eca8a1b9ccf86b58c1b8a9a6c5c5998956a (patch)
treef1e77a10168902b5a50e65bba6dd2fea8ce19469 /synapse/federation/federation_client.py
parentMerge branch 'develop' of github.com:matrix-org/synapse into develop (diff)
parentMore docs (diff)
downloadsynapse-1be67eca8a1b9ccf86b58c1b8a9a6c5c5998956a.tar.xz
Merge branch 'keyclient_retry_scheme' of github.com:matrix-org/synapse into develop
Diffstat (limited to 'synapse/federation/federation_client.py')
-rw-r--r--synapse/federation/federation_client.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py
index 6042e366bd..cd3c962d50 100644
--- a/synapse/federation/federation_client.py
+++ b/synapse/federation/federation_client.py
@@ -24,6 +24,8 @@ from synapse.util.expiringcache import ExpiringCache
 from synapse.util.logutils import log_function
 from synapse.events import FrozenEvent
 
+from synapse.util.retryutils import get_retry_limiter, NotRetryingDestination
+
 import logging
 
 
@@ -183,24 +185,32 @@ class FederationClient(FederationBase):
         pdu = None
         for destination in destinations:
             try:
-                transaction_data = yield self.transport_layer.get_event(
-                    destination, event_id
+                limiter = yield get_retry_limiter(
+                    destination,
+                    self._clock,
+                    self.store,
                 )
 
-                logger.debug("transaction_data %r", transaction_data)
+                with limiter:
+                    transaction_data = yield self.transport_layer.get_event(
+                        destination, event_id
+                    )
 
-                pdu_list = [
-                    self.event_from_pdu_json(p, outlier=outlier)
-                    for p in transaction_data["pdus"]
-                ]
+                    logger.debug("transaction_data %r", transaction_data)
+
+                    pdu_list = [
+                        self.event_from_pdu_json(p, outlier=outlier)
+                        for p in transaction_data["pdus"]
+                    ]
 
-                if pdu_list:
-                    pdu = pdu_list[0]
+                    if pdu_list:
+                        pdu = pdu_list[0]
 
-                    # Check signatures are correct.
-                    pdu = yield self._check_sigs_and_hash(pdu)
+                        # Check signatures are correct.
+                        pdu = yield self._check_sigs_and_hash(pdu)
+
+                        break
 
-                    break
             except SynapseError:
                 logger.info(
                     "Failed to get PDU %s from %s because %s",
@@ -216,6 +226,9 @@ class FederationClient(FederationBase):
                     event_id, destination, e,
                 )
                 continue
+            except NotRetryingDestination as e:
+                logger.info(e.message)
+                continue
             except Exception as e:
                 logger.info(
                     "Failed to get PDU %s from %s because %s",