code: def send(self, payloads, logger, num_tries=5):
          
          from time import sleep
  
          backoff_interval = 1
          backoff_factor = 2
  
          for try_counter in xrange(0, num_tries):
              failed_messages = self.send_without_retry(payloads)
  
              # success!
              if not failed_messages:
                  payloads = []
                  break
  
              # output some information about the failures for debugging
              # purposes. we expect failures to be quite rare, so we can be
              # pretty verbose.
              if logger:
                  for msg in failed_messages:
                      logger.warning("Failed to send message on try %d: Id=%r, "
                                     "SenderFault=%r, Code=%r, Message=%r" %
                                     (try_counter, msg['Id'],
                                      msg.get('SenderFault'), msg.get('Code'),
                                      msg.get('Message')))
  
              # wait a little while, in case the problem is that we're talking
              # too fast.
              sleep(backoff_interval)
              backoff_interval *= backoff_factor
  
              # filter out the failed payloads for retry
              retry_payloads = []
              for msg in failed_messages:
                  i = int(msg['Id'])
                  retry_payloads.append(payloads[i])
              payloads = retry_payloads
  
          if payloads:
              raise Exception('Messages failed to send to sqs after %d '
                              'retries: %s' % (num_tries, len(payloads)))
docs: Enqueue payloads to the SQS queue, retrying failed messages with
          exponential backoff.