def init_app(): global _db, _logs_dir, _k8s, _scheduler logger.info('configuration dump\n%s', config.dump_yaml()) if config.httpdb.db_type == 'sqldb': logger.info('using SQLDB') _db = SQLDB(config.httpdb.dsn) else: logger.info('using FileRunDB') _db = FileRunDB(config.httpdb.dirpath) _db.connect() _logs_dir = Path(config.httpdb.logs_path) try: _k8s = K8sHelper() except Exception: pass # @yaronha - Initialize here task = periodic.Task() periodic.schedule(task, 60) _scheduler = Scheduler() for data in _db.list_schedules(): if 'schedule' not in data: logger.warning('bad scheduler data - %s', data) continue _submit(data)
async def startup_event(): logger.info("configuration dump\n%s", config.dump_yaml()) initialize_singletons() task = periodic.Task() periodic.schedule(task, 60) _reschedule_tasks() _start_periodic_cleanup()
async def startup_event(): logger.info("configuration dump\n%s", config.dump_yaml()) initialize_singletons() # don't fail the app on re-scheduling failure try: task = periodic.Task() periodic.schedule(task, 60) _reschedule_tasks() except Exception as exc: logger.warning(f'Failed rescheduling tasks, err: {exc}') _start_periodic_cleanup()
def test_periodic(fail): t = Task(0.1, fail) freq = 0.2 periodic.schedule(t, freq) sleep(freq * 4) assert len(t.runs) >= 3, 'no runs'