summary refs log tree commit diff
path: root/synapse/http
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/http')
-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()