def METHOD_NAME(self, data, retry=True):
    if not self.sock:
        self.connect()
    try:
        self.sock.sendall(data)
    except socket.error as e:
        if retry:
            self.connect()
            self.METHOD_NAME(data, retry=False)
        else:
            print(f"Unhandled exception in NetlogConnection: {e}")
    except Exception as e:
        log.error("Unhandled exception in NetlogConnection: %s", e)
        # We really have nowhere to log this, if the netlog connection
        # does not work, we can assume that any logging won't work either.
        # So we just fail silently.
        self.close()