1
1
import threading
2
2
from getpass import getpass
3
- from typing import BinaryIO , Union
3
+ from typing import BinaryIO , Optional , Union
4
4
5
5
from dvc_objects .fs .base import AnyFSPath , FileSystem
6
6
from dvc_objects .fs .callbacks import DEFAULT_CALLBACK , Callback
@@ -88,6 +88,15 @@ def _prepare_credentials(self, **config):
88
88
# The connector should not be owned by aiohttp.ClientSession since
89
89
# it is closed by fsspec (HTTPFileSystem.close_session)
90
90
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
+ )
91
100
92
101
# Allow reading proxy configurations from the environment.
93
102
client_kwargs ["trust_env" ] = True
@@ -96,7 +105,13 @@ def _prepare_credentials(self, **config):
96
105
self .upload_method = config .get ("method" , "POST" )
97
106
return credentials
98
107
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
+ ):
100
115
import aiohttp
101
116
from aiohttp_retry import ExponentialRetry
102
117
@@ -116,9 +131,9 @@ async def get_client(self, **kwargs):
116
131
# time that is spent when connecting to the remote server.
117
132
kwargs ["timeout" ] = aiohttp .ClientTimeout (
118
133
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 ,
122
137
)
123
138
124
139
return ReadOnlyRetryClient (** kwargs )
0 commit comments