Beispiel #1
0
class Fetch_And_Download_Thread(threading.Thread):
    def __init__(self, local_file_folder):
        threading.Thread.__init__(self)
        self.local_file_folder = local_file_folder
        self.requests_utility = RequestsUtility()
    
    def run(self):
        while True:
            try:
                if not mp4_download_url_queue.empty():
                    download_url = mp4_download_url_queue.get(timeout=120)
                    print 'Start mp4 down from url: %s' % (download_url)
                    self.requests_utility.download_file(download_url, self.local_file_folder, stream=False)
                    mp4_download_url_queue.task_done()
                    print 'Finish mp4 down from url: %s' % (download_url)
                else:
                    time.sleep(3)
                    continue
            except Exception, e:
                print e
Beispiel #2
0
 def __init__(self, local_file_folder):
     threading.Thread.__init__(self)
     self.local_file_folder = local_file_folder
     self.requests_utility = RequestsUtility()