Skip to content

Commit 5d832bc

Browse files
committed
read timeout values from config (or fallback to default)
1 parent 81ac740 commit 5d832bc

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

dvc_http/__init__.py

Lines changed: 20 additions & 5 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, Union
3+
from typing import BinaryIO, Optional, Union
44

55
from dvc_objects.fs.base import AnyFSPath, FileSystem
66
from dvc_objects.fs.callbacks import DEFAULT_CALLBACK, Callback
@@ -88,6 +88,15 @@ def _prepare_credentials(self, **config):
8888
# The connector should not be owned by aiohttp.ClientSession since
8989
# it is closed by fsspec (HTTPFileSystem.close_session)
9090
client_kwargs["connector_owner"] = False
91+
client_kwargs["connect_timeout"] = config.get(
92+
"connect_timeout", self.REQUEST_TIMEOUT
93+
)
94+
client_kwargs["sock_connect_timeout"] = config.get(
95+
"sock_connect_timeout", self.REQUEST_TIMEOUT
96+
)
97+
client_kwargs["sock_read_timeout"] = config.get(
98+
"sock_read_timeout", self.REQUEST_TIMEOUT
99+
)
91100

92101
# Allow reading proxy configurations from the environment.
93102
client_kwargs["trust_env"] = True
@@ -96,7 +105,13 @@ def _prepare_credentials(self, **config):
96105
self.upload_method = config.get("method", "POST")
97106
return credentials
98107

99-
async def get_client(self, **kwargs):
108+
async def get_client(
109+
self,
110+
connect_timeout: Optional[float],
111+
sock_connect_timeout: Optional[float],
112+
sock_read_timeout: Optional[float],
113+
**kwargs,
114+
):
100115
import aiohttp
101116
from aiohttp_retry import ExponentialRetry
102117

@@ -116,9 +131,9 @@ async def get_client(self, **kwargs):
116131
# time that is spent when connecting to the remote server.
117132
kwargs["timeout"] = aiohttp.ClientTimeout(
118133
total=None,
119-
connect=self.REQUEST_TIMEOUT,
120-
sock_connect=self.REQUEST_TIMEOUT,
121-
sock_read=self.REQUEST_TIMEOUT,
134+
connect=connect_timeout,
135+
sock_connect=sock_connect_timeout,
136+
sock_read=sock_read_timeout,
122137
)
123138

124139
return ReadOnlyRetryClient(**kwargs)

0 commit comments

Comments
 (0)