def _load_data_in_thread_wrapper(self): """Wrapper for load data in thread.""" try: with self._load_data_lock: exception_wrapper(self._load_data()) except UnknownError as exc: # Not raising the exception here to ensure that data reloading does not crash. logger.warning(exc.message)
def _load_data_in_thread(self, reload_interval): """Wrapper for load data in thread.""" if self._load_data_lock.locked(): return try: with self._load_data_lock: while True: exception_wrapper(self._load_data)() if not reload_interval: break time.sleep(reload_interval) except UnknownError as exc: # Not raising the exception here to ensure that data reloading does not crash. logger.warning(exc.message)
def _load_in_cache(self): """Generate and execute loaders.""" def load(): self._generate_loaders() self._execute_load_data() try: exception_wrapper(load()) except UnknownError as ex: logger.warning("Load event data failed. Detail: %s.", str(ex)) finally: self._status = DetailCacheManagerStatus.DONE.value logger.info( "Load event data end, status: %r, and loader pool size is %r.", self._status, self.loader_pool_size())
def update_cache(self, executor): """ Update cache. Will switch to using disk_train_jobs in the future. Args: executor (Executor): The Executor instance. """ with self._loading_mutex: load_in_cache = exception_wrapper(self._execute_load_data) try: while not load_in_cache(executor): yield except UnknownError as ex: logger.warning("Load event data failed. Detail: %s.", str(ex))