def perform_task(self, task): # wait for tasks to finish and rejoin them if len(self.current_threads) > self.thread_number: gevent.join_all(self.current_threads) self.current_threads = [] self.current_threads.append(gevent.spawn(task.run))
def shutdown(self): logger.info("Shutting down gevent threads") return gevent.join_all(self.current_threads)