/
opt
/
gsutil
/
gslib
/
utils
/
__pycache__
/
up file
home
a +(Wgu � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlZddlm Z ddl mZ dd lm Z dd lmZ ejZddd �ZdS )zCShared utility structures and methods for handling request retries.� )�absolute_import)�print_function)�division)�unicode_literalsN)�http_wrapper)�thread_message)� constants)�retry_decoratorFc s$ � fdd�}� fdd�}| r |S |S )a Higher-order function allowing retry handler to access global status queue. Args: is_data_transfer: If True, disable retries in apitools. status_queue: The global status queue. Returns: A retry function for retryable errors in apitools. c sX | j dur$| j tjkr$t�d| j� � rJ� �tj| j t � � | j| j d�� t�| � dS )a� Exception handler for http failures in apitools. If the user has had to wait several seconds since their first request, print a progress message to the terminal to let them know we're still retrying, then perform the default retry logic and post a gslib.thread_message.RetryableErrorMessage to the global status queue. Args: retry_args: An apitools ExceptionRetryArgs tuple. Nz Retrying request, attempt #%d...��num_retries�total_wait_sec) r r �LONG_RETRY_WARN_SEC�logging�infor �putr �RetryableErrorMessage�exc�timer �)HandleExceptionsAndRebuildHttpConnections�� retry_args��status_queue� �%/opt/gsutil/gslib/utils/retry_util.py�WarnAfterManyRetriesHandler, s ���z8LogAndHandleRetries.<locals>.WarnAfterManyRetriesHandlerc s4 � r&� � tj| jt�� | j| jd�� t�| � dS )a- Exception handler that disables retries in apitools data transfers. Post a gslib.thread_message.RetryableErrorMessage to the global status queue. We handle the actual retries within the download and upload functions. Args: retry_args: An apitools ExceptionRetryArgs tuple. r N) r r r r r r r r �RethrowExceptionHandlerr r r r �RetriesInDataTransferHandlerC s ��z9LogAndHandleRetries.<locals>.RetriesInDataTransferHandlerr )�is_data_transferr r r r r r �LogAndHandleRetries! s r )FN)�__doc__� __future__r r r r r r �apitools.base.pyr �gslibr �gslib.utilsr r �retry�Retryr r r r r �<module> s