Optimize code
This commit is contained in:
parent
9a5239ab1d
commit
9087f27f2a
1 changed files with 6 additions and 5 deletions
|
@ -604,9 +604,9 @@ class DownloadGen(object):
|
|||
|
||||
def __next__(self):
|
||||
while True:
|
||||
if len(self.xml):
|
||||
self.current += 1
|
||||
try:
|
||||
child = self.xml[0]
|
||||
self.current += 1
|
||||
self.xml.remove(child)
|
||||
if (self.current % CONTAINERSIZE == 0 and
|
||||
self.current <= self.total - (self.cache_factor - 1) * CONTAINERSIZE):
|
||||
|
@ -614,10 +614,11 @@ class DownloadGen(object):
|
|||
self._download_chunk(
|
||||
start=self.current + (self.cache_factor - 1) * CONTAINERSIZE)
|
||||
return child
|
||||
app.APP.monitor.waitForAbort(0.1)
|
||||
except IndexError:
|
||||
if not self.pending_counter and not len(self.xml):
|
||||
raise StopIteration()
|
||||
LOG.debug('Waiting for download to finish')
|
||||
app.APP.monitor.waitForAbort(0.1)
|
||||
|
||||
next = __next__
|
||||
|
||||
|
|
Loading…
Reference in a new issue