'Wait for newly created instances and/or spot_requests to register in
the AWS API by repeatedly calling get_all_{instances, spot_requests}.
Calling this method directly after creating new instances or spot
requests before operating on them helps to avoid eventual consistency
errors about instances or spot requests not existing.'

def wait_for_propagation(self, instances=None, spot_requests=None, max_retries=60, interval=5):

    if spot_requests:
        spot_ids = [getattr(s, 'id', s) for s in spot_requests]
        self._wait_for_propagation(spot_ids, self.get_all_spot_requests, 'spot-instance-request-id', 'spot    requests', max_retries=max_retries, interval=interval)
    if instances:
        instance_ids = [getattr(i, 'id', i) for i in instances]
        self._wait_for_propagation(instance_ids, self.get_all_instances, 'instance-id', 'instances', max_retries=max_retries, interval=interval)
