code: def cmd(self, endpoints, cmd):
          
          replies = []
          for ep in endpoints:
              try:
                  replies.append(self._cmd(ep, cmd))
              except self.CmdFailed as ex:
                  # if there's only 1 endpoint, give up.
                  # if there's more, keep trying.
                  if len(endpoints) == 1:
                      raise ex
  
          return "".join(replies)
docs: endpoints is [(host1, port1), (host2, port), ...]