def close(self): self._validated = False if not self._owned: return try: k_utils.finalize_client(self._client) except (k_exc.KazooException, k_exc.ZookeeperError) as e: raise exc.StorageFailure("Unable to finalize client", e)
def close(self): if self._owned: LOG.debug("Stopping client") kazoo_utils.finalize_client(self._client) if self._worker is not None: LOG.debug("Shutting down the notifier") self._worker.shutdown() self._worker = None with self._job_cond: self._known_jobs.clear() LOG.debug("Stopped & cleared local state")
def close(self): if self._owned: LOG.debug("Stopping client") kazoo_utils.finalize_client(self._client) if self._worker is not None: LOG.debug("Shutting down the notifier") self._worker.shutdown() self._worker = None with self._job_lock: self._known_jobs.clear() LOG.debug("Stopped & cleared local state")
def clean_backend(backend, conf): with contextlib.closing(backend.get_connection()) as conn: try: conn.clear_all() except exc.NotFound: pass client = kazoo_utils.make_client(conf) client.start() try: client.delete(conf['path'], recursive=True) except kazoo_exceptions.NoNodeError: pass finally: kazoo_utils.finalize_client(client)
def zookeeper_available(min_version, timeout=3): client = kazoo_utils.make_client(ZK_TEST_CONFIG.copy()) try: # NOTE(imelnikov): 3 seconds we should be enough for localhost client.start(timeout=float(timeout)) if min_version: zk_ver = client.server_version() if zk_ver >= min_version: return True else: return False else: return True except Exception: return False finally: kazoo_utils.finalize_client(client)
def finalize_client(client): try: yield client finally: kazoo_utils.finalize_client(client)
def close_client(self, client): kazoo_utils.finalize_client(client)
def close(self): if self._owned: LOG.debug("Stopping client") kazoo_utils.finalize_client(self._client) self._clear() LOG.debug("Stopped & cleared local state")