From 086df807905178c0a9de8de61e50c31354c46bc3 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 28 May 2015 15:41:50 +0100 Subject: Add connection pooling to SimpleHttpClient --- synapse/http/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'synapse/http/client.py') diff --git a/synapse/http/client.py b/synapse/http/client.py index 5b3cefb2dc..9c7fa29369 100644 --- a/synapse/http/client.py +++ b/synapse/http/client.py @@ -20,7 +20,8 @@ import synapse.metrics from twisted.internet import defer, reactor from twisted.web.client import ( - Agent, readBody, FileBodyProducer, PartialDownloadError + Agent, readBody, FileBodyProducer, PartialDownloadError, + HTTPConnectionPool, ) from twisted.web.http_headers import Headers @@ -55,7 +56,8 @@ class SimpleHttpClient(object): # The default context factory in Twisted 14.0.0 (which we require) is # BrowserLikePolicyForHTTPS which will do regular cert validation # 'like a browser' - self.agent = Agent(reactor) + pool = HTTPConnectionPool(reactor) + self.agent = Agent(reactor, pool) self.version_string = hs.version_string def request(self, method, *args, **kwargs): -- cgit 1.4.1 From 11f51e6deda8962a7b027dff8b631f0af26a74d9 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 28 May 2015 15:45:46 +0100 Subject: Up maxPersistentPerHost count --- synapse/http/client.py | 1 + synapse/http/matrixfederationclient.py | 1 + 2 files changed, 2 insertions(+) (limited to 'synapse/http/client.py') diff --git a/synapse/http/client.py b/synapse/http/client.py index 9c7fa29369..8d6e89d6e7 100644 --- a/synapse/http/client.py +++ b/synapse/http/client.py @@ -57,6 +57,7 @@ class SimpleHttpClient(object): # BrowserLikePolicyForHTTPS which will do regular cert validation # 'like a browser' pool = HTTPConnectionPool(reactor) + pool.maxPersistentPerHost = 10 self.agent = Agent(reactor, pool) self.version_string = hs.version_string diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py index 9b6ba2d548..44f0b00333 100644 --- a/synapse/http/matrixfederationclient.py +++ b/synapse/http/matrixfederationclient.py @@ -104,6 +104,7 @@ class MatrixFederationHttpClient(object): self.signing_key = hs.config.signing_key[0] self.server_name = hs.hostname pool = HTTPConnectionPool(reactor) + pool.maxPersistentPerHost = 10 self.agent = MatrixFederationHttpAgent(reactor, pool) self.clock = hs.get_clock() self.version_string = hs.version_string -- cgit 1.4.1 From 79e37a7ecbb566f63393ee47728e5cddfdc2810e Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 28 May 2015 16:48:53 +0100 Subject: Correctly pass connection pool parameter --- synapse/http/client.py | 2 +- synapse/http/matrixfederationclient.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'synapse/http/client.py') diff --git a/synapse/http/client.py b/synapse/http/client.py index 8d6e89d6e7..e746f2416e 100644 --- a/synapse/http/client.py +++ b/synapse/http/client.py @@ -58,7 +58,7 @@ class SimpleHttpClient(object): # 'like a browser' pool = HTTPConnectionPool(reactor) pool.maxPersistentPerHost = 10 - self.agent = Agent(reactor, pool) + self.agent = Agent(reactor, pool=pool) self.version_string = hs.version_string def request(self, method, *args, **kwargs): diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py index 44f0b00333..7f3d8fc884 100644 --- a/synapse/http/matrixfederationclient.py +++ b/synapse/http/matrixfederationclient.py @@ -105,7 +105,7 @@ class MatrixFederationHttpClient(object): self.server_name = hs.hostname pool = HTTPConnectionPool(reactor) pool.maxPersistentPerHost = 10 - self.agent = MatrixFederationHttpAgent(reactor, pool) + self.agent = MatrixFederationHttpAgent(reactor, pool=pool) self.clock = hs.get_clock() self.version_string = hs.version_string -- cgit 1.4.1