def run(self): log.log(__name__, sys._getframe().f_code.co_name, "Start of thread downloads manager", log.LEVEL_DEBUG) self.event.clear() log.log(__name__, sys._getframe().f_code.co_name, "Start up => check if there are downloads to do", log.LEVEL_DEBUG) self.periodic_check() while True: downloads_list = ManageDownload.get_all_downloads_to_start() for download in downloads_list: log.log(__name__, sys._getframe().f_code.co_name, "Create thread for download id %d" % download.id, log.LEVEL_DEBUG) download_thread = DownloadThread(download, self.event, self.dict_event_download_mark_as_finished) download_thread.start() self.download_threads_list.append(download_thread) # for thread in self.download_threads_list: # thread.join() # log.log(__name__, sys._getframe().f_code.co_name, # "Remove thread for download id %d" % thread.download.id, log.LEVEL_DEBUG) # self.download_threads_list.remove(thread) # log.log(__name__, sys._getframe().f_code.co_name, # "Download finished => event setted", log.LEVEL_DEBUG) # self.event.set() log.log(__name__, sys._getframe().f_code.co_name, "Wait for event to start download ....", log.LEVEL_DEBUG) self.event.wait() self.event.clear() log.log(__name__, sys._getframe().f_code.co_name, "Event reveived !!", log.LEVEL_DEBUG) time.sleep(1)
def update(self): """ Try to download new images and update wallpaper. """ print "Updating..." download_thread = DownloadThread(self, self.ui_controller, self.config) download_thread.start()
def update(self): """ Try to download new images and update wallpaper. """ WallPaperLog.getInstance().info('Updating...') download_thread = DownloadThread(self, self.ui_controller, self.config) download_thread.start()
def update(self): """ Try to download new images and update wallpaper. """ print "Updating..." download_thread = DownloadThread(self, self.ui_controller, self.config) download_thread.start()
def run(self): try: self._tcpServer = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._tcpServer.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self._tcpServer.bind((self._config.ip, self._config.port)) except socket.error: self._log.error( "There was an error when trying to bind the server") exit(2) finally: self._log.info("Waiting for connections ...") while True: self._tcpServer.listen(4) (conn, (ip, port)) = self._tcpServer.accept() newthread = DownloadThread(conn, self._config) newthread.start() self.threads.append(newthread)