def send(self, s, attempt=0):
        if attempt >= 10:
            print "Dropping log message due to too many failed sends"
            return

        if self.sock is None:
            self.createSocket()

        if self.sock:
            try:
                # TODO: Weirdly, one the other ends drops the
                # connection for the next msg, sendall still reports
                # successful write on a disconnected socket but then
                # on subsequent writes it fails correctly.
                self.sock.sendall(s)
                return
            except socket.error:
                self.sock.close()
                self.sock = None

        # Here, we've failed to send s so retry
        reactor.callLater(1.5, lambda x: self.send(s, attempt + 1), None)
dataset/ETHPy150Open thinkst/opencanary/opencanary/logger.py/SocketJSONHandler.send/original