def GetBatchJobDownloadUrlWhenReady(client, batch_job_id,
                                    max_poll_attempts=MAX_POLL_ATTEMPTS):
  batch_job = GetBatchJob(client, batch_job_id)
  if batch_job['status'] == 'CANCELED':
    raise Exception('Batch Job with ID "%s" was canceled before completing.'
                    % batch_job_id)

  poll_attempt = 0

  while (poll_attempt in range(max_poll_attempts) and
         batch_job['status'] in PENDING_STATUSES):
    sleep_interval = (30 * (2 ** poll_attempt) +
                      (random.randint(0, 10000) / 1000))
    print 'Batch Job not ready, sleeping for %s seconds.' % sleep_interval
    time.sleep(sleep_interval)
    batch_job = GetBatchJob(client, batch_job_id)
    poll_attempt += 1

    if 'downloadUrl' in batch_job:
      url = batch_job['downloadUrl']['url']
      print ('Batch Job with Id "%s", Status "%s", and DownloadUrl "%s" ready.'
             % (batch_job['id'], batch_job['status'], url))
      return url

  print ('BatchJob with ID "%s" is being canceled because it was in a pending '
         'state after polling %d times.' % (batch_job_id, max_poll_attempts))
  CancelBatchJob(client, batch_job)
Create an HDF5 file and populate the fields. Return a file object.
dataset/ETHPy150Open googleads/googleads-python-lib/examples/adwords/v201509/campaign_management/add_keywords_using_incremental_batch_job.py/GetBatchJobDownloadUrlWhenReady--crossover with--dataset/ETHPy150Open neurodata/ndstore/test/ramon.py/H5AnnotationFile