mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-26 07:02:22 +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 = 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()
|
||||||
|
|
|
@ -31,15 +31,24 @@ class CustomScheduler(BaseScheduler):
|
||||||
self.scheduledb.save(task)
|
self.scheduledb.save(task)
|
||||||
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:
|
||||||
|
|
Loading…
Reference in a new issue