code: def ensure(self, connection, func, *args, **kwargs):
          
          channel = None
          while 1:
              try:
                  if channel is None:
                      channel = connection.channel()
                  return func(channel, *args, **kwargs), channel
              except (connection.connection_errors, IOError):
                  self._call_errback()
  
              channel = self.connect(connection)
docs: Perform an operation until success
  
          Repeats in the face of connection errors, pursuant to retry policy.