Browse Source

Fix delay problem

doc-issue-template
MrS0m30n3 10 years ago
parent
commit
3e435ddaec
1 changed files with 4 additions and 4 deletions
  1. 8
      youtube_dl_gui/DownloadThread.py

8
youtube_dl_gui/DownloadThread.py

@ -44,10 +44,11 @@ class DownloadManager(Thread):
url, index = self.extract_data() url, index = self.extract_data()
# Wait for your turn if there are not more positions in 'queue' # Wait for your turn if there are not more positions in 'queue'
while self.procNo >= MAX_DOWNLOAD_THREADS: while self.procNo >= MAX_DOWNLOAD_THREADS:
proc = self.check_queue(0.5)
proc = self.check_queue()
if proc != None: if proc != None:
self.procList.remove(proc) self.procList.remove(proc)
self.procNo -= 1 self.procNo -= 1
sleep(1)
# If we still running create new ProcessWrapper thread # If we still running create new ProcessWrapper thread
if self.running: if self.running:
self.procList.append( self.procList.append(
@ -65,7 +66,7 @@ class DownloadManager(Thread):
if not self.downloading(): if not self.downloading():
self.running = False self.running = False
else: else:
sleep(1)
sleep(0.1)
# If we reach here close down all child threads # If we reach here close down all child threads
self.terminate_all() self.terminate_all()
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, DataPack('finish')) CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, DataPack('finish'))
@ -91,12 +92,11 @@ class DownloadManager(Thread):
proc.close() proc.close()
proc.join() proc.join()
def check_queue(self, t=1):
def check_queue(self):
for proc in self.procList: for proc in self.procList:
if not self.running: break if not self.running: break
if not proc.isAlive(): if not proc.isAlive():
return proc return proc
sleep(t)
return None return None
def close(self): def close(self):

Loading…
Cancel
Save