summary refs log tree commit diff
path: root/synapse/http/federation
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-08-23 15:05:56 +0100
committerErik Johnston <erik@matrix.org>2019-08-23 15:37:20 +0100
commite70f0081da5bbea772316dffda5f173e9568d1d3 (patch)
treef43f42ae1fbf916ffd5dbd6edf5264dfd331686e /synapse/http/federation
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/reliable_l... (diff)
downloadsynapse-e70f0081da5bbea772316dffda5f173e9568d1d3.tar.xz
Fix logcontexts
Diffstat (limited to 'synapse/http/federation')
-rw-r--r--synapse/http/federation/matrix_federation_agent.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/synapse/http/federation/matrix_federation_agent.py b/synapse/http/federation/matrix_federation_agent.py
index a8815f078a..62883c06a4 100644
--- a/synapse/http/federation/matrix_federation_agent.py
+++ b/synapse/http/federation/matrix_federation_agent.py
@@ -28,7 +28,7 @@ from twisted.web.iweb import IAgent, IAgentEndpointFactory
 
 from synapse.http.federation.srv_resolver import Server, SrvResolver
 from synapse.http.federation.well_known_resolver import WellKnownResolver
-from synapse.logging.context import PreserveLoggingContext, make_deferred_yieldable
+from synapse.logging.context import make_deferred_yieldable, run_in_background
 from synapse.util import Clock
 
 logger = logging.getLogger(__name__)
@@ -158,8 +158,9 @@ class MatrixFederationAgent(object):
         if not headers.hasHeader(b"host"):
             headers.addRawHeader(b"host", parsed_uri.netloc)
 
-        with PreserveLoggingContext():
-            res = yield self._agent.request(method, uri, headers, bodyProducer)
+        res = yield make_deferred_yieldable(
+            self._agent.request(method, uri, headers, bodyProducer)
+        )
 
         return res
 
@@ -214,11 +215,14 @@ class MatrixHostnameEndpoint(object):
 
         self._srv_resolver = srv_resolver
 
-    @defer.inlineCallbacks
     def connect(self, protocol_factory):
         """Implements IStreamClientEndpoint interface
         """
 
+        return run_in_background(self._do_connect, protocol_factory)
+
+    @defer.inlineCallbacks
+    def _do_connect(self, protocol_factory):
         first_exception = None
 
         server_list = yield self._resolve_server()