[to #46522320]fix: fix download file timeout too short

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10961023

    * [to #46522320]fix: fix download file timeout too short
This commit is contained in:
mulin.lyh
2022-12-02 19:41:59 +08:00
parent e8608df930
commit b293095bd0
2 changed files with 4 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ REQUESTS_API_HTTP_METHOD = ['get', 'head', 'post', 'put', 'patch', 'delete']
API_HTTP_CLIENT_TIMEOUT = 60
API_RESPONSE_FIELD_DATA = 'Data'
API_FILE_DOWNLOAD_RETRY_TIMES = 5
API_FILE_DOWNLOAD_TIMEOUT = 60 * 5
API_FILE_DOWNLOAD_CHUNK_SIZE = 4096
API_RESPONSE_FIELD_GIT_ACCESS_TOKEN = 'AccessToken'
API_RESPONSE_FIELD_USERNAME = 'Username'

View File

@@ -15,7 +15,8 @@ from tqdm import tqdm
from modelscope import __version__
from modelscope.hub.api import HubApi, ModelScopeConfig
from modelscope.hub.constants import (API_FILE_DOWNLOAD_CHUNK_SIZE,
API_FILE_DOWNLOAD_RETRY_TIMES, FILE_HASH)
API_FILE_DOWNLOAD_RETRY_TIMES,
API_FILE_DOWNLOAD_TIMEOUT, FILE_HASH)
from modelscope.utils.constant import DEFAULT_MODEL_REVISION
from modelscope.utils.logger import get_logger
from .errors import FileDownloadError, NotExistError
@@ -220,7 +221,7 @@ def http_get_file(
stream=True,
headers=get_headers,
cookies=cookies,
timeout=5)
timeout=API_FILE_DOWNLOAD_TIMEOUT)
r.raise_for_status()
content_length = r.headers.get('Content-Length')
total = int(