Skip to content

Commit 5baea49

Browse files
committed
Downloader: Make timeout configurable
If the user wants to have a timeout, it's now possible. Signed-off-by: kingbri <bdashore3@proton.me>
1 parent 78625df commit 5baea49

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

async-hf-downloader/download.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ async def entrypoint(args):
126126
print(f"Saving to {str(download_path)}")
127127

128128
try:
129-
timeout = aiohttp.ClientTimeout(total=None) # Turn off timeout
130-
async with aiohttp.ClientSession(timeout=timeout) as session:
129+
client_timeout = aiohttp.ClientTimeout(total=args.timeout) # Turn off timeout
130+
async with aiohttp.ClientSession(timeout=client_timeout) as session:
131131
tasks = []
132132
print(f"Starting download for {args.repo_id}")
133133

@@ -194,7 +194,8 @@ async def entrypoint(args):
194194
"Skips all sanity checks such as "
195195
"checking if the destination directory exists"
196196
),
197-
)
197+
),
198+
parser.add_argument("--timeout", type=int, help="Optional request timeout in seconds")
198199

199200
args = parser.parse_args()
200201

0 commit comments

Comments
 (0)