async def heartbeat(self): if self.closing: return await self.ensure_safe_state() try: zxid, _ = await self.conn.send(protocol.PingRequest()) self.last_zxid = zxid except exc.ConnectError: self.state.transition_to(States.SUSPENDED) finally: self.set_heartbeat()
async def heartbeat(self): if self.closing: return await self.ensure_safe_state() try: timeout = self.timeout - self.timeout / HEARTBEAT_FREQUENCY zxid, _ = await asyncio.wait_for( self.conn.send(protocol.PingRequest()), timeout) self.last_zxid = zxid except (exc.ConnectError, asyncio.TimeoutError): if self.state != States.SUSPENDED: self.state.transition_to(States.SUSPENDED) except Exception as e: log.exception('in heartbeat: {}'.format(e)) raise e finally: self.set_heartbeat()