def test_task(task): """ Dummy task for basic testing. """ time.sleep(task) log.debug("test_task[" + str(task) + "] called")
def run(self): """ Start worker. """ log.info("worker started") while True: task_name, _callable, args, kwds = self.task_queue.get() log.debug("worker got " + task_name) # pylint: disable-msg=W0142 results = _callable(*args, **kwds) # pylint: enable-msg=W0142 if results is False: log.error("Task failed: " + task_name)
def run(self): """ Check the tasks queue and run anything that is due. """ while True: while self.current_workers < self.total_workers: log.debug("worker added") app.worker.Worker(self.active_queue) self.current_workers += 1 self.process_pending_list() self.process_active_list() self.process_done_list() log.info('active_queue = ' + str(self.active_queue.qsize())) time.sleep(app.config.TIMER_SLEEP_INTERVAL) log.debug("waking")