mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 04:57:54 +00:00
Clean up cached HTTP connections on shutdown.
This commit is contained in:
parent
94a91b68c0
commit
c92c93e6d5
0
newsfragments/4028.minor
Normal file
0
newsfragments/4028.minor
Normal file
@ -310,6 +310,7 @@ class StorageClient(object):
|
||||
_base_url: DecodedURL
|
||||
_swissnum: bytes
|
||||
_treq: Union[treq, StubTreq, HTTPClient]
|
||||
_pool: HTTPConnectionPool
|
||||
_clock: IReactorTime
|
||||
|
||||
@classmethod
|
||||
@ -339,7 +340,7 @@ class StorageClient(object):
|
||||
)
|
||||
|
||||
https_url = DecodedURL().replace(scheme="https", host=nurl.host, port=nurl.port)
|
||||
return cls(https_url, swissnum, treq_client, reactor)
|
||||
return cls(https_url, swissnum, treq_client, pool, reactor)
|
||||
|
||||
def relative_url(self, path: str) -> DecodedURL:
|
||||
"""Get a URL relative to the base URL."""
|
||||
@ -479,6 +480,10 @@ class StorageClient(object):
|
||||
).read()
|
||||
raise ClientException(response.code, response.phrase, data)
|
||||
|
||||
def shutdown(self) -> Deferred:
|
||||
"""Shutdown any connections."""
|
||||
return self._pool.closeCachedConnections()
|
||||
|
||||
|
||||
@define(hash=True)
|
||||
class StorageClientGeneral(object):
|
||||
|
@ -1271,6 +1271,11 @@ class HTTPNativeStorageServer(service.MultiService):
|
||||
if self._lc.running:
|
||||
self._lc.stop()
|
||||
self._failed_to_connect("shut down")
|
||||
|
||||
maybe_storage_server = self.get_storage_server()
|
||||
if maybe_storage_server is not None:
|
||||
result.addCallback(lambda _: maybe_storage_server._http_client.shutdown())
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user