def make_readonly_master(run_scheduler=False): """Prepare a readonly master.""" treadmill_sched.DIMENSION_COUNT = 3 backend = zkbackend.ZkReadonlyBackend(context.GLOBAL.zk.conn) # set timezone to master's data = backend.get('/') if data and 'timezone' in data: _LOGGER.debug('Setting timezone to %s', data['timezone']) os.environ['TZ'] = data['timezone'] time.tzset() else: _LOGGER.warning('Missing timezone info.') cell_master = loader.Loader( backend, context.GLOBAL.cell ) cell_master.load_model() if run_scheduler: cell_master.cell.schedule() return cell_master
def make_readonly_master(run_scheduler=False): """Prepare a readonly master.""" treadmill_sched.DIMENSION_COUNT = 3 cell_master = loader.Loader( zkbackend.ZkReadonlyBackend(context.GLOBAL.zk.conn), context.GLOBAL.cell ) cell_master.load_model() if run_scheduler: cell_master.cell.schedule() return cell_master
def get_readonly_scheduler(): """Prepare a readonly master.""" # C0103(invalid-name): invalid variable name # W0603(global-statement): using the global statement # pylint: disable=C0103,W0603 global _RO_SHEDULER_INSTANCE, _LAST_CACHE_UPDATE if (time.time() - _LAST_CACHE_UPDATE > _CACHE_TIMEOUT or not _RO_SHEDULER_INSTANCE): tm_sched.DIMENSION_COUNT = 3 _RO_SHEDULER_INSTANCE = loader.Loader( zkbackend.ZkReadonlyBackend(context.GLOBAL.zk.conn), context.GLOBAL.cell) _RO_SHEDULER_INSTANCE.load_model() _LAST_CACHE_UPDATE = time.time() return _RO_SHEDULER_INSTANCE