Merge pull request #61 from matrix-org/timeout-federation-requests

Timeout federation requests
This commit is contained in:
Erik Johnston 2015-02-11 17:10:33 +00:00
commit c52e8d395b
3 changed files with 63 additions and 2 deletions

View file

@ -79,6 +79,7 @@ class MatrixFederationHttpClient(object):
self.signing_key = hs.config.signing_key[0]
self.server_name = hs.hostname
self.agent = MatrixFederationHttpAgent(reactor)
self.clock = hs.get_clock()
@defer.inlineCallbacks
def _create_request(self, destination, method, path_bytes,
@ -118,7 +119,7 @@ class MatrixFederationHttpClient(object):
try:
with PreserveLoggingContext():
response = yield self.agent.request(
request_deferred = self.agent.request(
destination,
endpoint,
method,
@ -129,6 +130,11 @@ class MatrixFederationHttpClient(object):
producer
)
response = yield self.clock.time_bound_deferred(
request_deferred,
time_out=60,
)
logger.debug("Got response to %s", method)
break
except Exception as e: