diff --git a/src/allmydata/storage/http_client.py b/src/allmydata/storage/http_client.py index 3edf5f835..1d798fecc 100644 --- a/src/allmydata/storage/http_client.py +++ b/src/allmydata/storage/http_client.py @@ -311,21 +311,18 @@ class StorageClient(object): @classmethod def from_nurl( - cls, nurl: DecodedURL, reactor, persistent=True, retryAutomatically=True + cls, nurl: DecodedURL, reactor, pool: Optional[HTTPConnectionPool] = None ) -> StorageClient: """ Create a ``StorageClient`` for the given NURL. - - ``persistent`` and ``retryAutomatically`` arguments are passed to the - new HTTPConnectionPool. """ assert nurl.fragment == "v=1" assert nurl.scheme == "pb" swissnum = nurl.path[0].encode("ascii") certificate_hash = nurl.user.encode("ascii") - pool = HTTPConnectionPool(reactor, persistent=persistent) - pool.retryAutomatically = retryAutomatically - pool.maxPersistentPerHost = 20 + if pool is None: + pool = HTTPConnectionPool(reactor) + pool.maxPersistentPerHost = 20 if cls.TEST_MODE_REGISTER_HTTP_POOL is not None: cls.TEST_MODE_REGISTER_HTTP_POOL(pool) diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index 2888b10e7..19d6ef4a7 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -43,6 +43,7 @@ from configparser import NoSectionError import attr from hyperlink import DecodedURL +from twisted.web.client import HTTPConnectionPool from zope.interface import ( Attribute, Interface, @@ -1205,10 +1206,10 @@ class HTTPNativeStorageServer(service.MultiService): def request(reactor, nurl: DecodedURL): # Since we're just using this one off to check if the NURL # works, no need for persistent pool or other fanciness. + pool = HTTPConnectionPool(reactor, persistent=False) + pool.retryAutomatically = False return StorageClientGeneral( - StorageClient.from_nurl( - nurl, reactor, persistent=False, retryAutomatically=False - ) + StorageClient.from_nurl(nurl, reactor, pool) ).get_version() # LoopingCall.stop() doesn't cancel Deferreds, unfortunately: