def _keep_alive_thread(self): while self._running: with self._connections_lock: for connection in self._connections.values(): try: connection.send(PingPacket.make()) except (IOError, BrokenPipeError): self._disconnect(connection) time.sleep(30)
def _keep_alive_thread(self): while self._running: logging.info("KEEP ALIVE THREAD: Acquiring connection lock") with self._connections_lock: logging.info("KEEP ALIVE: connection lock acquired") for connection in self._connections.values(): try: connection.send(PingPacket.make()) except (IOError, BrokenPipeError): self._disconnect(connection) logging.info("KEEP ALIVE: connection lock released") time.sleep(30)