Optimize code

This commit is contained in:
croneter 2018-12-21 16:03:56 +01:00
parent 9a5239ab1d
commit 9087f27f2a

View file

@ -604,9 +604,9 @@ class DownloadGen(object):
def __next__(self): def __next__(self):
while True: while True:
if len(self.xml): try:
self.current += 1
child = self.xml[0] child = self.xml[0]
self.current += 1
self.xml.remove(child) self.xml.remove(child)
if (self.current % CONTAINERSIZE == 0 and if (self.current % CONTAINERSIZE == 0 and
self.current <= self.total - (self.cache_factor - 1) * CONTAINERSIZE): self.current <= self.total - (self.cache_factor - 1) * CONTAINERSIZE):
@ -614,10 +614,11 @@ class DownloadGen(object):
self._download_chunk( self._download_chunk(
start=self.current + (self.cache_factor - 1) * CONTAINERSIZE) start=self.current + (self.cache_factor - 1) * CONTAINERSIZE)
return child return child
app.APP.monitor.waitForAbort(0.1) except IndexError:
if not self.pending_counter and not len(self.xml): if not self.pending_counter and not len(self.xml):
raise StopIteration() raise StopIteration()
LOG.debug('Waiting for download to finish') LOG.debug('Waiting for download to finish')
app.APP.monitor.waitForAbort(0.1)
next = __next__ next = __next__