def _safeio(self, callback):
        for i in range(self.retries):
            if self.sock is None:
                self.sock = self.listener.reaccept(self.cookie)
                if self.blocking_mode is not None:
                    self.sock.setblocking(self.blocking_mode)

            try:
                return callback(self.sock)
            except (EOFError, IOError, OSError, socket.error):
                if i >= self.retries - 1:
                    raise
                if self.sock:
                    self.sock.close()
                self.sock = None
dataset/ETHPy150Open tomerfiliba/rpyc/rpyc/experimental/retunnel.py/ReconnectingSocket._safeio/original