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.setDaemon(True)
sc_thread.start()
return scheduler_ins
def init_event_manager(self):
eventManager = EventManager()

View file

@ -31,15 +31,24 @@ class CustomScheduler(BaseScheduler):
self.scheduledb.save(task)
self.events.append(ScheduleTaskJob(task))
def remove_job(self,task):
self.scheduledb.delete(task)
def remove_job(self, task):
for event in self.events:
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)
def stop(self):
self.keep_run = False
def list_schedule_tasks(self):
return self.scheduledb.load()
def run(self):
t = datetime(*datetime.now().timetuple()[:5])
while 1 and self.keep_run: