def getInactiveDownload(self): self.__mutex.acquire() c = self.__activeDownloadCount self.__mutex.release() if c >= globalvars.max_simultaneous_download: return None self.__mutex.acquire() for i in range(0, len(self.__downloads)): if self.__counter >= len(self.__downloads): self.__counter = 0 download = self.__downloads[self.__counter] self.__counter += 1 if download.isActive(): continue download.setActive(1) self.__activeDownloadCount += 1 self.__mutex.release() return download self.__mutex.release() return None
def __start_download(self, download): if not download.fetch(): download.setActive(0) self.__mutex.acquire() self.__activeDownloadCount -= 1 self.__mutex.release()