mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-12-23 14:32:18 +03:00
added remove schedule job via task id method
This commit is contained in:
parent
a68ea26f79
commit
a341deefee
2 changed files with 12 additions and 2 deletions
|
@ -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()
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue