def _retry_fetch(url, retry_params, **kwds):
  n = 1
  start_time = time.time()
  delay = retry_params.delay(n, start_time)
  if delay <= 0:
    return

  logging.info('Will retry request to %s.', url)
  while delay > 0:
    resp = None
    try:
      logging.info('Retry in %s seconds.', delay)
      time.sleep(delay)
      resp = urlfetch.fetch(url, **kwds)
    except runtime.DeadlineExceededError:
      logging.info(
          'Urlfetch retry %s will exceed request deadline '
          'after %s seconds total', n, time.time() - start_time)
      raise
    except _RETRIABLE_EXCEPTIONS, e:
      pass

    n += 1
    delay = retry_params.delay(n, start_time)
    if resp and not _should_retry(resp):
      break
    elif resp:
      logging.info(
          'Got status %s from GCS.', resp.status_code)
    else:
      logging.info(
          'Got exception "%r" while contacting GCS.', e)

  if resp:
    return resp

  logging.info('Urlfetch failed after %s retries and %s seconds in total.',
               n - 1, time.time() - start_time)
  raise
Commits a transaction and resets the dirty flag.
dataset/ETHPy150Open GoogleCloudPlatform/appengine-opencv-sudoku-python/cloudstorage/api_utils.py/_retry_fetch--crossover with--dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/db/transaction.py/commit