Don't bother with persistent connections when testing NURLs.

This commit is contained in:
Itamar Turner-Trauring 2023-03-14 13:01:10 -04:00
parent f8ea650b92
commit dd07a39399
2 changed files with 11 additions and 5 deletions

View File

@ -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:

View File

@ -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: