code: def wait_for_compose(self, compose_id,
                           burst_retry=1,
                           burst_length=30,
                           slow_retry=10,
                           timeout=1800):
          
          logger.debug("Getting compose information for information for compose_id={}"
                       .format(compose_id))
          url = '{}composes/{}'.format(self.url, compose_id)
          start_time = time.time()
          while True:
              response = self.session.get(url)
              response.raise_for_status()
              response_json = response.json()
  
              if response_json['state_name'] == 'failed':
                  state_reason = response_json.get('state_reason', 'Unknown')
                  logger.error(dedent("""\
                     Compose %s failed: %s
                     Details: %s
                     """), compose_id, state_reason, json.dumps(response_json, indent=4))
                  raise RuntimeError('Failed request for compose_id={}: {}'
                                     .format(compose_id, state_reason))
  
              if response_json['state_name'] not in ['wait', 'generating']:
                  logger.debug("Retrieved compose information for compose_id={}: {}"
                               .format(compose_id, json.dumps(response_json, indent=4)))
                  return response_json
  
              elapsed = time.time() - start_time
              if elapsed > timeout:
                  raise RuntimeError("Retrieving %s timed out after %s seconds" %
                                     (url, timeout))
              else:
                  logger.debug("Retrying request compose_id={}, elapsed_time={}"
                               .format(compose_id, elapsed))
  
                  if elapsed > burst_length:
                      time.sleep(slow_retry)
                  else:
                      time.sleep(burst_retry)
docs: Wait for compose request to finalize
  
          :param compose_id: int, compose ID to wait for
          :param burst_retry: int, seconds to wait between retries prior to exceeding
                              the burst length
          :param burst_length: int, seconds to switch to slower retry period
          :param slow_retry: int, seconds to wait between retries after exceeding
                             the burst length
          :param timeout: int, when to give up waiting for compose request
  
          :return: dict, updated status of compose.
          :raise RuntimeError: if state_name becomes 'failed'