From e98967731952208896e78cf8e1b697b367c6f8a0 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Tue, 21 Mar 2023 11:20:25 -0400 Subject: [PATCH] Pass in a pool instead of pool options. --- src/allmydata/storage/http_client.py | 11 ++++------- src/allmydata/storage_client.py | 7 ++++--- 2 files changed, 8 insertions(+), 10 deletions(-) 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: