def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except Exception as e: # pragma: no cover log.warning("[Timer] Scheduler error: %s", str(e))
def __runScheduler(self, sched): maxSleep = 3 while True: # print("Scheduling thread") try: wTime = sched.run(blocking=False) except Exception as e: logger.error("Exception in shedule event: %s", e) logger.exception(e) if wTime is None or wTime > maxSleep: wTime = maxSleep time.sleep(wTime)
def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except Exception: pass
def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except: pass
self.printLog("[CHECK END]") def getTime(self): return datetime.datetime.now() def printLog(self, msg): with open(self.log_path, 'a') as f: f.write("\n" + msg) def rmComma(self, stri): return stri.replace(",", "") sched = sched.scheduler(time.time, time.sleep) php = PHPWatchDog() if php.error: print("\n[ERROR]Cannot read the config file.") exit() def start(sc): php.test() sched.enter(php.delay, 1, start, (sc, )) print("[START] PHPWatchDog started at [ " + str(php.getTime()) + " ]") php.printLog("[START] PHPWatchDog started at [ " + str(php.getTime()) + " ]") php.test() sched.enter(php.delay, 1, start, (sched, )) sched.run()
def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except: #pylint:disable=bare-except pass
def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except: # pylint:disable=bare-except pass
def main(): sched.enter(1, 1, run_request, (sched, )) sched.run()
for name, obj in inspect.getmembers(mod): if inspect.isclass(obj) and name != 'Module': obj = obj(module['config']) if 'config' in module else obj() widget = obj.widget() components[module['label']] = {'object': obj, 'widget': widget} if obj.refreshrate is not None: sched.enter(obj.refreshrate, 1, refresh, (module['label'], widget, obj.refreshrate)) return (assets, components) # Initialise all the modules of the application # and launch their automatic scheduled update sched = sched.scheduler(time.time, time.sleep) assets, components = loadmodules([ {'label' : 'datetime', 'name': 'datetime'}, ]) threading.Thread(target=lambda: sched.run()).start() # Initialise the websocket server endpoint queue = queue.Queue() clients = set() class MyServerProtocol(WebSocketServerProtocol): def __init__(self): super().__init__() clients.add(self) def onConnect(self, request): super().onConnect(request) def succeedHandshake(self, res): super().succeedHandshake(res)
from sched import run, switch async def coro1(): print("C1: Start") await switch() print("C1: a") await switch() print("C1: b") await switch() print("C1: c") await switch() print("C1: Stop") async def coro2(): print("C2: Start") await switch() print("C2: a") await switch() print("C2: b") await switch() print("C2: c") await switch() print("C2: Stop") run([coro1(), coro2()])
def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except Exception as e: log.warning("[Timer] Scheduler error: %s", str(e))
def main(): sched.enter(1, 1, sqlping, (sched, )) sched.run()