async def setUp(self): self.clients = [] self.c = ZKClient(HOST, chroot='/test_aiozk') await self.c.start() if len(await self.c.get_children('/')) > 0: await self.c.deleteall('') await self.c.create('')
async def _assure_connected(self): if self._zk is None: self._zk = ZKClient(servers=self._servers, chroot=self._working_path) await self._zk.start() if self._auth is not None: auth_req = AuthRequest(type=0, **self._auth) await self._zk.send(auth_req)
def __init__(self, zk_path, chroot='/', with_data_watcher=True, loop=None): super().__init__() self.chroot = chroot self.with_data_watcher = with_data_watcher self.closing = False self.loop = loop self.check_zk_task = None self.zk = ZKClient(zk_path, chroot, loop=loop)
async def run(): # await asyncio.sleep(10) logging.debug('Start') zk = ZKClient('zk', session_timeout=3) await zk.start() while 1: try: await zk.exists('/zookeeper') c = zk.session.conn ip = c.host_ip logging.debug('DIAG Curr conn: {}'.format( [socket.gethostbyaddr(c.host_ip)[0]])) except Exception as e: logging.error('DIAG Exc: {}'.format(e)) await asyncio.sleep(1)
async def client(self): c = ZKClient(HOST, chroot='/test_aiozk') await c.start() self.clients.append(c) return c
def get_client(): return ZKClient(HOST, chroot='/test_aiozk')
async def __aenter__(self): wait_socket(self.seed, 2181) self.zk = ZKClient(self.seed) await self.zk.start() return self.zk
def get_client(loop=None): return ZKClient(HOST, chroot='/test_aiozk', loop=loop)
async def setUp(self): self.zk = ZKClient(self.zk_path) await self.zk.start()