def run(): scheduler.start() try: asyncio.get_event_loop().run_forever() except (KeyboardInterrupt, SystemExit): print("Shutting down. Please wait...") scheduler.shutdown(wait=True) exit(0)
def setUp(self): scheduler.start() self.app = create_app('testing') self.client = self.app.test_client self.devices = {'name': 'test'} with self.app.app_context(): db.create_all() db.session.add(Device(name='Test Fan', device_id='L-20', device_type=DeviceType.FAN)) db.session.add(Device(name='Test RF', device_id='101-1', device_type=DeviceType.RF)) db.session.commit()
def run_process(sender): init_sender(sender) update_timestamp(sender) def update(): update_subscribers(sender) listen_and_deliver(sender) update_timestamp(sender) print("Waiting", datetime.datetime.now()) print() scheduler.add_job(update, 'interval', minutes=1) scheduler.start()
async def main(): await notify("Tromino: Starting...") scheduler.start() await notify("Tromino: Scheduler up") monitor_types = monitors.load_monitors() await notify(f"Tromino: Loading plugins - {', '.join([m for m in monitor_types])}") # job = scheduler.add_job(lambda: print(1), "interval", seconds=5) monitor_instances = await Monitor.load_all() await notify(f"Tromino: Loading monitor instances - {len(monitor_instances)}") for m in monitor_instances: try: await monitor_instances[m].job_start() await notify(f"Tromino: Starting {m}") except JobAlreadyStarted: pass await run_server() await notify("Tromino: HTTP Server stared") await notify("Tromino: Hello ! What could I do for you ?")
""" MAIN APP """ import os from app import create_app from scheduler import scheduler app_env = os.getenv('ENVIRONMENT', 'development') app = create_app(app_env) if __name__ == "__main__": scheduler.start() if app_env == 'deployment': app.run(host='0.0.0.0') else: app.run(host='0.0.0.0')
def ready(self): from scheduler import scheduler if settings.SCHEDULER_AUTOSTART: #turn off when using pytest scheduler.start()
def ready(self): from scheduler import scheduler scheduler.start()
def _run(): try: scheduler.start() app.run(threaded=True, use_reloader=False, processes=1) except KeyboardInterrupt, SystemExit: scheduler.shutdown()
''' Heroku scheduler will invoke this script every 10 minutes. This is necessary to start cron jobs created at Tron CI. ''' from scheduler import scheduler import logging import time logging.basicConfig( level=logging.DEBUG, format='[%(asctime)s]: %(levelname)s : %(message)s' ) logger = logging.getLogger(__name__) logger.info('Reloading Tron CI scheduler') scheduler.start() # Giving enough time to restore and execute all jobs. time.sleep(30) # Shutdown scheduler after all jobs has finished. scheduler.shutdown() while scheduler.running: pass logger.info('Reload process finished')