From e084f76c5edd1e52065432fe20c16616292c2172 Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Thu, 6 Apr 2023 19:52:23 +0800 Subject: [PATCH] fix --- utils/NetUtils.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/utils/NetUtils.py b/utils/NetUtils.py index a84a1ca..15ffa92 100644 --- a/utils/NetUtils.py +++ b/utils/NetUtils.py @@ -169,11 +169,7 @@ class downloadUtils: } @classmethod - def queueDownClear(cls): cls.QUEUE_DOWN = Queue() - - @classmethod - def putDownUrlDirFileType(cls,url,dir,file,type): - cls.QUEUE_DOWN.put([url,dir,file,type]) + def putDownUrlDirFileType(cls,url,dir,file,type): cls.QUEUE_DOWN.put([url,dir,file,type]) @classmethod def getDownUrlDirFileType(cls): @@ -245,10 +241,13 @@ class downloadUtils: logger.debug(f"concurrency= {concurrency}") with concurrent.futures.ThreadPoolExecutor(max_workers=concurrency) as executor: future_list = list() - while not cls.QUEUE_DOWN.empty(): - result = cls.QUEUE_DOWN.get(False) - (file_url,dir,file,file_type) = [result[0],result[1],result[2],result[3]] - future_list.append(executor.submit(cls.common_download, + while True: + result = cls.getDownUrlDirFileType() + if result != None: + (file_url,dir,file,file_type) = [result[0],result[1],result[2],result[3]] + future_list.append(executor.submit(cls.common_download, file_url,dir,file,file_type, timeout=timeout, proxy_type=proxy_type, proxy=proxy)) + else: + break concurrent.futures.wait(future_list, timeout) \ No newline at end of file