(retry_state: tenacity.RetryCallState)
return False
Return True if we should retry.

  False otherwise.

  Args:
    retry_state: A retry state including exception to test for transience.

  Returns:
    True if we should retry. False otherwise.
Return True if we should retry.
Return True if we should retry .
def retry_api_check(retry_state: tenacity.RetryCallState) -> bool:
  """Return True if we should retry.

  False otherwise.

  Args:
    retry_state: A retry state including exception to test for transience.

  Returns:
    True if we should retry. False otherwise.
  """
  exception = retry_state.outcome.exception()
  attempt_number = retry_state.attempt_number
  now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')

  if isinstance(exception, googleapiclient.errors.HttpError):
    if exception.resp.status in TRANSIENT_HTTP_ERROR_CODES:
      _print_retry_error(attempt_number, MAX_API_ATTEMPTS, exception)
      return True

  if isinstance(exception, socket.error):
    if exception.errno in TRANSIENT_SOCKET_ERROR_CODES:
      _print_retry_error(attempt_number, MAX_API_ATTEMPTS, exception)
      return True

  if isinstance(exception, socket.timeout):
    _print_retry_error(attempt_number, MAX_API_ATTEMPTS, exception)
    return True

  if isinstance(exception, google.auth.exceptions.RefreshError):
    _print_retry_error(attempt_number, MAX_API_ATTEMPTS, exception)
    return True

  # For a given installation, this could be a permanent error, but has only
  # been observed as transient.
  if isinstance(exception, ssl.SSLError):
    _print_retry_error(attempt_number, MAX_API_ATTEMPTS, exception)
    return True

  # This has been observed as a transient error:
  #   ServerNotFoundError: Unable to find the server at genomics.googleapis.com
  if isinstance(exception, httplib2.ServerNotFoundError):
    _print_retry_error(attempt_number, MAX_API_ATTEMPTS, exception)
    return True

  # Observed to be thrown transiently from auth libraries which use httplib2
  if isinstance(exception, http.client.ResponseNotReady):
    _print_retry_error(attempt_number, MAX_API_ATTEMPTS, exception)
    return True

  if not exception and attempt_number > 5:
    _print_error('{}: Retry SUCCEEDED'.format(now))

  return False
def retry_api_check ( retry_state : tenacity . RetryCallState ) -> bool : exception = retry_state . outcome . exception ( ) attempt_number = retry_state . attempt_number now = datetime . datetime . now ( ) . strftime ( '%Y-%m-%d %H:%M:%S.%f' ) if isinstance ( exception , googleapiclient . errors . HttpError ) : if exception . resp . status in TRANSIENT_HTTP_ERROR_CODES : _print_retry_error ( attempt_number , MAX_API_ATTEMPTS , exception ) return True if isinstance ( exception , socket . error ) : if exception . errno in TRANSIENT_SOCKET_ERROR_CODES : _print_retry_error ( attempt_number , MAX_API_ATTEMPTS , exception ) return True if isinstance ( exception , socket . timeout ) : _print_retry_error ( attempt_number , MAX_API_ATTEMPTS , exception ) return True if isinstance ( exception , google . auth . exceptions . RefreshError ) : _print_retry_error ( attempt_number , MAX_API_ATTEMPTS , exception ) return True # For a given installation, this could be a permanent error, but has only # been observed as transient. if isinstance ( exception , ssl . SSLError ) : _print_retry_error ( attempt_number , MAX_API_ATTEMPTS , exception ) return True # This has been observed as a transient error: #   ServerNotFoundError: Unable to find the server at genomics.googleapis.com if isinstance ( exception , httplib2 . ServerNotFoundError ) : _print_retry_error ( attempt_number , MAX_API_ATTEMPTS , exception ) return True # Observed to be thrown transiently from auth libraries which use httplib2 if isinstance ( exception , http . client . ResponseNotReady ) : _print_retry_error ( attempt_number , MAX_API_ATTEMPTS , exception ) return True if not exception and attempt_number > 5 : _print_error ( '{}: Retry SUCCEEDED' . format ( now ) ) return False