From 879c9bd7d6e886f7fd5fc122155302e8176e70be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Mon, 14 Mar 2022 09:08:07 +0100 Subject: [PATCH] fs.http: force cleanup of closed connections --- dvc/fs/http.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dvc/fs/http.py b/dvc/fs/http.py index d19372810..f03ea37b3 100644 --- a/dvc/fs/http.py +++ b/dvc/fs/http.py @@ -81,11 +81,20 @@ class HTTPFileSystem(NoDirectoriesMixin, FSSpecWrapper): f"Auth method {auth_method!r} is not supported." ) + # Force cleanup of closed SSL transports. + # https://github.com/iterative/dvc/issues/7414 + connector_kwargs = {"enable_cleanup_closed": True} + if "ssl_verify" in config: - with fsspec_loop(): - client_kwargs["connector"] = aiohttp.TCPConnector( - ssl=make_context(config["ssl_verify"]) - ) + connector_kwargs.update(ssl=make_context(config["ssl_verify"])) + + with fsspec_loop(): + client_kwargs["connector"] = aiohttp.TCPConnector( + **connector_kwargs + ) + # The connector should not be owned by aiohttp.ClientSession since + # it is closed by fsspec (HTTPFileSystem.close_session) + client_kwargs["connector_owner"] = False # Allow reading proxy configurations from the environment. client_kwargs["trust_env"] = True