def ping(self): log.debug("PingThread started") while True: self.ping_thread_event.wait(self.PING_INTERVAL) if self.ping_thread_event.is_set(): break try: self._send(functions.PingDelayDisconnect(0, self.PING_INTERVAL + 15), False) except (OSError, TimeoutError): pass log.debug("PingThread stopped")
def ping(self): log.debug("PingThread started") while True: self.ping_thread_event.wait(self.PING_INTERVAL) if self.ping_thread_event.is_set(): break try: self._send(functions.PingDelayDisconnect( ping_id=0, disconnect_delay=self.WAIT_TIMEOUT + 10 ), False) except (OSError, TimeoutError, RPCError): pass log.debug("PingThread stopped")
async def ping(self): log.info("PingTask started") while True: try: await asyncio.wait_for(self.ping_task_event.wait(), self.PING_INTERVAL) except asyncio.TimeoutError: pass else: break try: await self._send( functions.PingDelayDisconnect( ping_id=0, disconnect_delay=self.WAIT_TIMEOUT + 10), False) except (OSError, TimeoutError, RPCError): pass log.info("PingTask stopped")