def _buildbucket_retry(operation_name, http, *args, **kwargs):
    'Retries requests to buildbucket service and returns parsed json content.'
    try_count = 0
    while True:
        (response, content) = http.request(*args, **kwargs)
        try:
            content_json = json.loads(content)
        except ValueError:
            content_json = None
        if (content_json and content_json.get('error')):
            error = content_json.get('error')
            if (error.get('code') == 403):
                raise BuildbucketResponseException(('Access denied: %s' % error.get('message', '')))
            msg = ('Error in response. Reason: %s. Message: %s.' % (error.get('reason', ''), error.get('message', '')))
            raise BuildbucketResponseException(msg)
        if (response.status == 200):
            if (not content_json):
                raise BuildbucketResponseException(('Buildbucket returns invalid json content: %s.\nPlease file bugs at http://crbug.com, label "Infra-BuildBucket".' % content))
            return content_json
        if ((response.status < 500) or (try_count >= 2)):
            raise httplib2.HttpLib2Error(content)
        logging.debug('Transient errors when %s. Will retry.', operation_name)
        time.sleep((0.5 + (1.5 * try_count)))
        try_count += 1
    assert False, 'unreachable'
Retries requests to buildbucket service and returns parsed json content.
def _buildbucket_retry(operation_name, http, *args, **kwargs):
    
    try_count = 0
    while True:
        (response, content) = http.request(*args, **kwargs)
        try:
            content_json = json.loads(content)
        except ValueError:
            content_json = None
        if (content_json and content_json.get('error')):
            error = content_json.get('error')
            if (error.get('code') == 403):
                raise BuildbucketResponseException(('Access denied: %s' % error.get('message', )))
            msg = ('Error in response. Reason: %s. Message: %s.' % (error.get('reason', ), error.get('message', )))
            raise BuildbucketResponseException(msg)
        if (response.status == 200):
            if (not content_json):
                raise BuildbucketResponseException(('Buildbucket returns invalid json content: %s.\nPlease file bugs at http://crbug.com, label "Infra-BuildBucket".' % content))
            return content_json
        if ((response.status < 500) or (try_count >= 2)):
            raise httplib2.HttpLib2Error(content)
        logging.debug('Transient errors when %s. Will retry.', operation_name)
        time.sleep((0.5 + (1.5 * try_count)))
        try_count += 1
    assert False, 'unreachable'