mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-15 09:02:17 +03:00
41 lines
957 B
Python
41 lines
957 B
Python
|
#!/usr/bin/python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||
|
|
||
|
from base.scheduler.base_scheduler import BaseScheduler
|
||
|
from base.Scope import Scope
|
||
|
from datetime import datetime, timedelta
|
||
|
import time
|
||
|
|
||
|
|
||
|
class CustomScheduler(BaseScheduler):
|
||
|
|
||
|
def __init__(self):
|
||
|
self.events = []
|
||
|
self.keep_run = True
|
||
|
self.logger = Scope.getInstance().getLogger()
|
||
|
|
||
|
def initialize(self):
|
||
|
# Implement this from your implementation class
|
||
|
pass
|
||
|
|
||
|
def add_job(self,job):
|
||
|
self.events.append(job)
|
||
|
|
||
|
def stop(self):
|
||
|
self.keep_run = False
|
||
|
|
||
|
def run(self):
|
||
|
t = datetime(*datetime.now().timetuple()[:5])
|
||
|
while 1 and self.keep_run:
|
||
|
for e in self.events:
|
||
|
e.check(t)
|
||
|
|
||
|
t += timedelta(minutes=1)
|
||
|
while datetime.now() < t:
|
||
|
time.sleep((t - datetime.now()).seconds)
|
||
|
|
||
|
|
||
|
|
||
|
|