From d074a3ade7686af08e6e78c5f3733bff879495bc Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Tue, 6 Dec 2022 23:06:22 +0800 Subject: [PATCH] fixt --- utils/downloader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/downloader.py b/utils/downloader.py index 94fa6d9..8b9fb23 100644 --- a/utils/downloader.py +++ b/utils/downloader.py @@ -48,10 +48,13 @@ def download_image(image_url, dst_dir, file_name, timeout=20, proxy_type=None, p except Exception as e: if response: response.close() + if repair_count < 5: + download_image(image_url,dst_dir,file_name) + repair_count += 1 print("## Fail: {} {}".format(image_url, e.args)) -def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, timeout=360, proxy_type=None, proxy=None,filesName=None): +def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, timeout=20, proxy_type=None, proxy=None,filesName=None): """ Download image according to given urls and automatically rename them in order. :param timeout: @@ -74,4 +77,4 @@ def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, time future_list.append(executor.submit( download_image, image_url, dst_dir, file_name, timeout, proxy_type, proxy)) count += 1 - concurrent.futures.wait(future_list, timeout=360) \ No newline at end of file + concurrent.futures.wait(future_list, timeout=180) \ No newline at end of file