def wait(self, numtasks=None): pbar = self.progress_bar.reset() pbar.maxval = self.unfinished_tasks if numtasks is not None: pbar.maxval = max(numtasks, self.unfinished_tasks) while self.unfinished_tasks != 0: finished = pbar.maxval - self.unfinished_tasks pbar.update(finished) log.debug("unfinished_tasks = %d" % self.unfinished_tasks) time.sleep(1) if pbar.maxval != 0: pbar.finish() self.join() if self._exception_queue.qsize() > 0: raise exception.ThreadPoolException( "An error occured in ThreadPool", self._exception_queue.queue)
def wait(self, numtasks=None, return_results=True): pbar = self.progress_bar.reset() pbar.maxval = self.unfinished_tasks if numtasks is not None: pbar.maxval = max(numtasks, self.unfinished_tasks) while self.unfinished_tasks != 0: finished = pbar.maxval - self.unfinished_tasks pbar.update(finished) log.debug("unfinished_tasks = %d" % self.unfinished_tasks) time.sleep(1) if pbar.maxval != 0: pbar.finish() self.join() exc_queue = self._exception_queue if exc_queue.qsize() > 0: excs = [exc_queue.get() for i in range(exc_queue.qsize())] raise exception.ThreadPoolException( "An error occurred in ThreadPool", excs) if return_results: return self.get_results()