From dd07a39399709b59d7c1c1e2e0cb5d3ac4d6ff65 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Tue, 14 Mar 2023 13:01:10 -0400 Subject: [PATCH] Don't bother with persistent connections when testing NURLs. --- src/allmydata/storage/http_client.py | 10 ++++++---- src/allmydata/storage_client.py | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/allmydata/storage/http_client.py b/src/allmydata/storage/http_client.py index 90bda7fc0..3edf5f835 100644 --- a/src/allmydata/storage/http_client.py +++ b/src/allmydata/storage/http_client.py @@ -311,18 +311,20 @@ class StorageClient(object): @classmethod def from_nurl( - cls, - nurl: DecodedURL, - reactor, + cls, nurl: DecodedURL, reactor, persistent=True, retryAutomatically=True ) -> 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) + pool = HTTPConnectionPool(reactor, persistent=persistent) + pool.retryAutomatically = retryAutomatically pool.maxPersistentPerHost = 20 if cls.TEST_MODE_REGISTER_HTTP_POOL is not None: diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index faa48710f..2888b10e7 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -1203,8 +1203,12 @@ class HTTPNativeStorageServer(service.MultiService): # the HTTP server to talk to, we don't have connection status # updates... https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3978 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. return StorageClientGeneral( - StorageClient.from_nurl(nurl, reactor) + StorageClient.from_nurl( + nurl, reactor, persistent=False, retryAutomatically=False + ) ).get_version() # LoopingCall.stop() doesn't cancel Deferreds, unfortunately: