]> gitweb.fluxo.info Git - ckandumper.git/commitdiff
Cleanup
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 16 May 2019 19:52:32 +0000 (16:52 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 16 May 2019 19:52:32 +0000 (16:52 -0300)
ckandumper

index 121f33b9e53562ee8b230f7b22120c9eb313c7cd..a7464d8d482a717afa6119b981f202fd14577402 100755 (executable)
@@ -119,13 +119,14 @@ class DownloadMultiple:
 
             return proc.returncode
 
-    async def gather(self, filepairs, progress_bar):
+    async def gather(self, filepairs):
         """Gather all files to be downloaded
 
         See https://stackoverflow.com/questions/50308812/is-it-possible-to-limit-the-number-of-coroutines-running-corcurrently-in-asyncio#50328882
         """
 
-        jobs = []
+        jobs         = []
+        progress_bar = tqdm(total=len(filepairs)) if self.progress and len(filepairs) > 1 else False
 
         for url, filename in filepairs:
           jobs.append(asyncio.ensure_future(self.download_file(url, filename, self.limit_concurrent, progress_bar)))
@@ -133,12 +134,11 @@ class DownloadMultiple:
         await asyncio.gather(*jobs)
 
     def get(self, filepairs):
-        self.stats   =  { 'exitstatus': {} }
-        progress_bar = tqdm(total=len(filepairs)) if self.progress and len(filepairs) > 1 else False
-        loop         = asyncio.get_event_loop()
+        self.stats =  { 'exitstatus': {} }
+        loop       = asyncio.get_event_loop()
 
         loop.set_debug(self.debug)
-        loop.run_until_complete(self.gather(filepairs, progress_bar))
+        loop.run_until_complete(self.gather(filepairs))
 
         if self.debug:
             print(self.stats)