code: def send_data(self, data=None):
          
          save_in_error = False
          if not data:
              if self.__data_lock.acquire():
                  data = self.__data
                  self.__data = []
                  save_in_error = True
                  self.__data_lock.release()
              else:
                  return False
          s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          payload = pickle.dumps(data, protocol=2)
          header = struct.pack("!L", len(payload))
          message = header + payload
          s.settimeout(1)
          s.connect((self.host, self.port))
          try:
              s.send(message)
          except:
              # log.exception('Error when sending data to carbon')
              if save_in_error:
                  self.__data.extend(data)
              return False
          else:
              # log.debug('Sent data to {host}:{port}: {0} metrics, {1} bytes'.format(len(data),
              #   len(message), host = self.host, port=self.port))
              return True
          finally:
              s.close()
docs: If data is empty, current buffer is sent. Otherwise data must be like:
          data = [('metricname', (timestamp, value)),
                ('metricname', (timestamp, value)),
                ...]