Skip to content

Commit 4e81adb

Browse files
committed
_prepare_credentials: connector fix for fsspec>=2022.12
simplify _prepare credentials, revert some of the changes related to iterative/dvc#7414
1 parent fe2ae8e commit 4e81adb

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

dvc_http/__init__.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import threading
22
from getpass import getpass
3-
from typing import BinaryIO, Optional, Union
3+
from typing import Any, BinaryIO, Dict, Optional, Union
44

55
from dvc_objects.fs.base import AnyFSPath, FileSystem
66
from dvc_objects.fs.callbacks import DEFAULT_CALLBACK, Callback
@@ -40,7 +40,6 @@ class HTTPFileSystem(FileSystem):
4040

4141
def _prepare_credentials(self, **config):
4242
import aiohttp
43-
from fsspec.asyn import fsspec_loop
4443

4544
credentials = {}
4645
client_kwargs = credentials.setdefault("client_kwargs", {})
@@ -74,20 +73,11 @@ def _prepare_credentials(self, **config):
7473
f"Auth method {auth_method!r} is not supported."
7574
)
7675

77-
# Force cleanup of closed SSL transports.
78-
# https://github.com/iterative/dvc/issues/7414
79-
connector_kwargs = {"enable_cleanup_closed": True}
80-
8176
if "ssl_verify" in config:
82-
connector_kwargs.update(ssl=make_context(config["ssl_verify"]))
83-
84-
with fsspec_loop():
85-
client_kwargs["connector"] = aiohttp.TCPConnector(
86-
**connector_kwargs
87-
)
88-
# The connector should not be owned by aiohttp.ClientSession since
89-
# it is closed by fsspec (HTTPFileSystem.close_session)
90-
client_kwargs["connector_owner"] = False
77+
client_kwargs["connector_kwargs"] = {
78+
"ssl": make_context(config["ssl_verify"])
79+
}
80+
9181
client_kwargs["connect_timeout"] = config.get(
9282
"connect_timeout", self.REQUEST_TIMEOUT
9383
)
@@ -110,6 +100,7 @@ async def get_client(
110100
connect_timeout: Optional[float],
111101
sock_connect_timeout: Optional[float],
112102
sock_read_timeout: Optional[float],
103+
connector_kwargs: Optional[Dict[str, Any]] = None,
113104
**kwargs,
114105
):
115106
import aiohttp
@@ -136,6 +127,9 @@ async def get_client(
136127
sock_read=sock_read_timeout,
137128
)
138129

130+
if connector_kwargs:
131+
kwargs["connector"] = aiohttp.TCPConnector(**connector_kwargs)
132+
139133
return ReadOnlyRetryClient(**kwargs)
140134

141135
@cached_property

0 commit comments

Comments
 (0)