added remove schedule job via task id method

This commit is contained in:
İsmail Başaran 2016-04-05 19:12:40 +03:00
parent a68ea26f79
commit a341deefee
2 changed files with 12 additions and 2 deletions

View file

@ -55,6 +55,7 @@ class AhenkDeamon(BaseDaemon):
sc_thread = threading.Thread(target=scheduler_ins.run) sc_thread = threading.Thread(target=scheduler_ins.run)
sc_thread.setDaemon(True) sc_thread.setDaemon(True)
sc_thread.start() sc_thread.start()
return scheduler_ins
def init_event_manager(self): def init_event_manager(self):
eventManager = EventManager() eventManager = EventManager()

View file

@ -32,14 +32,23 @@ class CustomScheduler(BaseScheduler):
self.events.append(ScheduleTaskJob(task)) self.events.append(ScheduleTaskJob(task))
def remove_job(self, task): def remove_job(self, task):
self.scheduledb.delete(task)
for event in self.events: for event in self.events:
if event.task.id == task.id: if event.task.id == task.id:
self.scheduledb.delete(task)
self.events.remove(event)
def remove_job_via_task_id(self,task_id):
for event in self.events:
if event.task.id == task_id:
self.scheduledb.delete(event.task)
self.events.remove(event) self.events.remove(event)
def stop(self): def stop(self):
self.keep_run = False self.keep_run = False
def list_schedule_tasks(self):
return self.scheduledb.load()
def run(self): def run(self):
t = datetime(*datetime.now().timetuple()[:5]) t = datetime(*datetime.now().timetuple()[:5])
while 1 and self.keep_run: while 1 and self.keep_run: