def runTaskNow(self, uuid): for task in self._tasks: if task.getUuid() == uuid: if task.isRunning(): log.info("Telling task %s to run now" % task.name) task.runNow() else: log.info("Restarting task %s" % task.name) task.setRunning() return True log.info("No task with uuid %s found" % uuid) return False
def stopAllTasks(self): """Stop all task threads""" msg = "Stopping all tasks" xdm.common.SM.setNewMessage(msg) log.info(msg) for task in self._tasks: msg = 'Stopping scheduled task %s' % task.name xdm.common.SM.setNewMessage(msg) log.info(msg) if not (task.isSleeping() or not task.isRunning()): msg = 'Looks like %s is running. checking in 1 second again' % task.name xdm.common.SM.setNewMessage(msg) log.info(msg) time.sleep(1) if not (task.isSleeping() or not task.isRunning()): msg = 'Looks like %s is really running. please wait...' % task.name xdm.common.SM.setNewMessage(msg) log.info(msg) task.stop() task.join() continue task.stop() task.join(0)