HEX
Server: Apache
System: Linux aura.ambarhosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User: chicagos (1295)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/s3transfer/futures.pyc
�
P$�_c@s�ddlmZddlmZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZm
Z
ddlmZddlmZeje�Zd	efd
��YZdefd��YZd
efd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZeddg�Zed�Z ed �Z!dS(!i����(tfutures(t
namedtupleN(tMAXINT(tsix(tCancelledErrortTransferNotDoneError(tFunctionContainer(t
TaskSemaphoretBaseTransferFuturecBs2eZed��Zd�Zd�Zd�ZRS(cCstd��dS(s-The metadata associated to the TransferFuturetmetaN(tNotImplementedError(tself((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR	scCstd��dS(smDetermines if a TransferFuture has completed

        :returns: True if completed. False, otherwise.
        sdone()N(R
(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytdone$scCstd��dS(s�Waits until TransferFuture is done and returns the result

        If the TransferFuture succeeded, it will return the result. If the
        TransferFuture failed, it will raise the exception associated to the
        failure.
        sresult()N(R
(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytresult+scCstd��dS(s6Cancels the request associated with the TransferFuturescancel()N(R
(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytcancel4s(t__name__t
__module__tpropertyR	RR
R(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRs			tBaseTransferMetacBs5eZed��Zed��Zed��ZRS(cCstd��dS(s*The call args used in the transfer requestt	call_argsN(R
(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR:scCstd��dS(sThe unique id of the transferttransfer_idN(R
(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR?scCstd��dS(s.A dictionary that requesters can store data intuser_contextN(R
(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRDs(RRRRRR(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR9stTransferFuturecBsJeZddd�Zed��Zd�Zd�Zd�Zd�Z	RS(cCsL||_|dkr$t�|_n||_|dkrHt�|_ndS(s�The future associated to a submitted transfer request

        :type meta: TransferMeta
        :param meta: The metadata associated to the request. This object
            is visible to the requester.

        :type coordinator: TransferCoordinator
        :param coordinator: The coordinator associated to the request. This
            object is not visible to the requester.
        N(t_metatNonetTransferMetat_coordinatortTransferCoordinator(RR	tcoordinator((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyt__init__Ks		cCs|jS(N(R(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR	^scCs
|jj�S(N(RR(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRbscCs;y|jj�SWn#tk
r6}|j�|�nXdS(N(RR
tKeyboardInterruptR(Rte((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR
es

cCs|jj�dS(N(RR(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRoscCs5|j�std��n|jj|dt�dS(s!Sets the exception on the future.s?set_exception can only be called once the transfer is complete.toverrideN(RRRt
set_exceptiontTrue(Rt	exception((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR!rsN(
RRRRRR	RR
RR!(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRJs		
	RcBsbeZdZddd�Zed��Zed��Zed��Zed��Z	d�Z
RS(s'Holds metadata about the TransferFuturecCs(||_||_d|_i|_dS(N(t
_call_argst_transfer_idRt_sizet
_user_context(RRR((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR}s			cCs|jS(s*The call args used in the transfer request(R$(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�scCs|jS(sThe unique id of the transfer(R%(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�scCs|jS(s)The size of the transfer request if known(R&(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytsize�scCs|jS(s.A dictionary that requesters can store data in(R'(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�scCs
||_dS(s�A method to provide the size of a transfer request

        By providing this value, the TransferManager will not try to
        call HeadObject or use the use OS to determine the size of the
        transfer.
        N(R&(RR(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytprovide_transfer_size�sN(RRt__doc__RRRRRR(RR)(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR{sRcBs
eZdZdd�Zd�Zed��Zed��Zed��Z	ed��Z
d�Zed�Z
d	�Zd
ed�Zd�Zd
�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(s*A helper class for managing TransferFuturecCs�||_d|_d|_d|_t�|_g|_g|_t	j
�|_t	j�|_
t	j�|_t	j�|_t	j�|_dS(Nsnot-started(Rt_statusRt_resultt
_exceptiontsett_associated_futurest_failure_cleanupst_done_callbackst	threadingtEventt_done_eventtLockt_lockt_associated_futures_lockt_done_callbacks_lockt_failure_cleanups_lock(RR((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�s						cCsd|jj|jfS(Ns%s(transfer_id=%s)(t	__class__RR(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyt__repr__�scCs|jS(N(R-(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR#�scCs$|j�tj|j�SWdQXdS(s�The list of futures associated to the inprogress TransferFuture

        Once the transfer finishes this list becomes empty as the transfer
        is considered done and there should be no running futures left.
        N(R7tcopyR/(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytassociated_futures�s
cCs|jS(s;The list of callbacks to call when the TransferFuture fails(R0(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytfailure_cleanups�scCs|jS(s�The status of the TransferFuture

        The currently supported states are:
            * not-started - Has yet to start. If in this state, a transfer
              can be canceled immediately and nothing will happen.
            * queued - SubmissionTask is about to submit tasks
            * running - Is inprogress. In-progress as of now means that
              the SubmissionTask that runs the transfer is being executed. So
              there is no guarantee any transfer requests had been made to
              S3 if this state is reached.
            * cancelled - Was cancelled
            * failed - An exception other than CancelledError was thrown
            * success - No exceptions were thrown and is done.
        (R+(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytstatus�scCs/|j� d|_||_d|_WdQXdS(s�Set a result for the TransferFuture

        Implies that the TransferFuture succeeded. This will always set a
        result because it is invoked on the final task where there is only
        ever one final task and it is ran at the very end of a transfer
        process. So if a result is being set for this final task, the transfer
        succeeded even if something came a long and canceled the transfer
        on the final task.
        tsuccessN(R6RR-R,R+(RR
((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyt
set_result�s

		cCs<|j�-|j�s|r2||_d|_nWdQXdS(s�Set an exception for the TransferFuture

        Implies the TransferFuture failed.

        :param exception: The exception that cause the transfer to fail.
        :param override: If True, override any existing state.
        tfailedN(R6RR-R+(RR#R ((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR!�s
	cCs,|jjt�|jr%|j�n|jS(s�Waits until TransferFuture is done and returns the result

        If the TransferFuture succeeded, it will return the result. If the
        TransferFuture failed, it will raise the exception associated to the
        failure.
        (R4twaitRR-R,(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR
�s	tcCs|j�p|j�sut}tjd||�||�|_|jdkrVt}nd|_|ru|j�qunWdQXdS(s�Cancels the TransferFuture

        :param msg: The message to attach to the cancellation
        :param exc_type: The type of exception to set for the cancellation
        s%s cancel(%s) calledsnot-startedt	cancelledN(	R6RtFalsetloggertdebugR-R+R"t
announce_done(Rtmsgtexc_typetshould_announce_done((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRs
		cCs|jd�dS(s+Sets the TransferFutrue's status to runningtqueuedN(t_transition_to_non_done_state(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytset_status_to_queuedscCs|jd�dS(s+Sets the TransferFuture's status to runningtrunningN(RN(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytset_status_to_running!scCsE|j�6|j�r2td|j|f��n||_WdQXdS(Ns=Unable to transition from done state %s to non-done state %s.(R6RtRuntimeErrorR?R+(Rt
desired_state((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRN%s
cCs\tjd|||jf�|j|d|�}|j|�|jt|j|��|S(s�Submits a task to a provided executor

        :type executor: s3transfer.futures.BoundedExecutor
        :param executor: The executor to submit the callable to

        :type task: s3transfer.tasks.Task
        :param task: The task to submit to the executor

        :type tag: s3transfer.futures.TaskTag
        :param tag: A tag to associate to the submitted task

        :rtype: concurrent.futures.Future
        :returns: A future representing the submitted task
        s;Submitting task %s to executor %s for transfer request: %s.ttag(RGRHRtsubmittadd_associated_futuretadd_done_callbackRtremove_associated_future(RtexecutorttaskRTtfuture((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRU-s
cCs
|jdkS(s�Determines if a TransferFuture has completed

        :returns: False if status is equal to 'failed', 'cancelled', or
            'success'. True, otherwise
        RBRER@(sfaileds	cancelledssuccess(R?(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRHscCs$|j�|jj|�WdQXdS(s6Adds a future to be associated with the TransferFutureN(R7R/tadd(RR[((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRVPs
cCs$|j�|jj|�WdQXdS(s4Removes a future's association to the TransferFutureN(R7R/tremove(RR[((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRXUs
c	Os0|j�!|jjt|||��WdQXdS(s7Add a done callback to be invoked when transfer is doneN(R8R1tappendR(Rtfunctiontargstkwargs((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRWZs
	c	Os0|j�!|jjt|||��WdQXdS(s$Adds a callback to call upon failureN(R9R0R^R(RR_R`Ra((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pytadd_failure_cleanupas
	cCs7|jdkr|j�n|jj�|j�dS(sMAnnounce that future is done running and run associated callbacks

        This will run any failure cleanups if the transfer failed if not
        they have not been run, allows the result() to be unblocked, and will
        run any done callbacks associated to the TransferFuture if they have
        not already been ran.
        R@N(R?t_run_failure_cleanupsR4R.t_run_done_callbacks(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRIgs

cCs-|j�|j|j�g|_WdQXdS(N(R8t_run_callbacksR1(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRdts
cCs-|j�|j|j�g|_WdQXdS(N(R9ReR>R0(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRc|s
cCs"x|D]}|j|�qWdS(N(t
_run_callback(Rt	callbackstcallback((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRe�s
cCs:y|�Wn(tk
r5tjd|dt�nXdS(NsException raised in %s.texc_info(t	ExceptionRGRHR"(RRh((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRf�s
N(RRR*RRR;RR#R=R>R?RARFR!R
RRRORQRNRURRVRXRWRbRIRdRcReRf(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�s2	
	
										
			tBoundedExecutorcBs;eZejZddd�Zded�Zed�Z	RS(cCsR||_|dkr!|j}n|d|j�|_t|�|_||_dS(sDAn executor implentation that has a maximum queued up tasks

        The executor will block if the number of tasks that have been
        submitted and is currently working on is past its maximum.

        :params max_size: The maximum number of inflight futures. An inflight
            future means that the task is either queued up or is currently
            being executed. A size of None or 0 means that the executor will
            have no bound in terms of the number of inflight futures.

        :params max_num_threads: The maximum number of threads the executor
            uses.

        :type tag_semaphores: dict
        :params tag_semaphores: A dictionary where the key is the name of the
            tag and the value is the semaphore to use when limiting the
            number of tasks the executor is processing at a time.

        :type executor_cls: BaseExecutor
        :param underlying_executor_cls: The executor class that
            get bounded by this executor. If None is provided, the
            concurrent.futures.ThreadPoolExecutor class is used.
        tmax_workersN(t_max_num_threadsRtEXECUTOR_CLSt	_executorRt
_semaphoret_tag_semaphores(Rtmax_sizetmax_num_threadsttag_semaphorestexecutor_cls((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�s	cCsu|j}|r|j|}n|j|j|�}t|j|j|�}t|jj|��}|j	|�|S(s1Submit a task to complete

        :type task: s3transfer.tasks.Task
        :param task: The task to run __call__ on


        :type tag: s3transfer.futures.TaskTag
        :param tag: An optional tag to associate to the task. This
            is used to override which semaphore to use.

        :type block: boolean
        :param block: True if to wait till it is possible to submit a task.
            False, if not to wait and raise an error if not able to submit
            a task.

        :returns: The future assocaited to the submitted task
        (
RpRqtacquireRRtreleasetExecutorFutureRoRURW(RRZRTtblockt	semaphoret
acquire_tokentrelease_callbackR[((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRU�s	
cCs|jj|�dS(N(Rotshutdown(RRC((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR}�sN(
RRRtThreadPoolExecutorRnRRR"RUR}(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRk�s
	%RxcBs,eZd�Zd�Zd�Zd�ZRS(cCs
||_dS(s�A future returned from the executor

        Currently, it is just a wrapper around a concurrent.futures.Future.
        However, this can eventually grow to implement the needed functionality
        of concurrent.futures.Future if we move off of the library and not
        affect the rest of the codebase.

        :type future: concurrent.futures.Future
        :param future: The underlying future
        N(t_future(RR[((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�scCs
|jj�S(N(RR
(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR
�scs#�fd�}|jj|�dS(sAdds a callback to be completed once future is done

        :parm fn: A callable that takes no arguments. Note that is different
            than concurrent.futures.Future.add_done_callback that requires
            a single argument for the future.
        cs��S(N((tfuture_passed_to_callback(tfn(s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyt
done_callback�sN(RRW(RR�R�((R�s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRW�s
cCs
|jj�S(N(RR(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�s(RRRR
RWR(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRx�s	
		tBaseExecutorcBs/eZdZdd�Zd�Zed�ZRS(sABase Executor class implementation needed to work with s3transfercCsdS(N((RRl((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRscOstd��dS(Nssubmit()(R
(RR�R`Ra((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRUscCstd��dS(Ns
shutdown()(R
(RRC((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR}sN(RRR*RRRUR"R}(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�s	tNonThreadedExecutorcBs#eZdZd�Zed�ZRS(s@A drop-in replacement non-threaded version of ThreadPoolExecutorcOs}t�}y |||�}|j|�WnMtk
rxtj�d\}}tjd|||�|j||�nX|S(Nis0Setting exception for %s to %s with traceback %s(tNonThreadedExecutorFutureRARjtsysRiRGRHtset_exception_info(RR�R`RaR[R
Rttb((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRUs	

cCsdS(N((RRC((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR}s(RRR*RUR"R}(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�s	R�cBsYeZdZd�Zd�Zd�Zd	d�Zd�Zd�Z	d�Z
d�ZRS(
s�The Future returned from NonThreadedExecutor

    Note that this future is **not** thread-safe as it is being used
    from the context of a non-threaded environment.
    cCs1d|_d|_d|_t|_g|_dS(N(RR,R-t
_tracebackRFt_doneR1(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR&s
				cCs||_|j�dS(N(R,t	_set_done(RR
((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRA-s	cCs ||_||_|j�dS(N(R-R�R�(RR#t	traceback((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�1s		cCs5|jr.tjt|j�|j|j�n|jS(N(R-RtreraisettypeR�R,(Rttimeout((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR
6s	cCs7t|_x|jD]}|j|�qWg|_dS(N(R"R�R1t_invoke_done_callback(RR�((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�<s	cCs
||�S(N((RR�((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR�BscCs|jS(N(R�(R((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyREscCs-|jr|j|�n|jj|�dS(N(R�R�R1R^(RR�((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyRWHs	N(RRR*RRAR�RR
R�R�RRW(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyR� s						tTaskTagtnametin_memory_uploadtin_memory_download("t
concurrentRtcollectionsRR<tloggingR�R2ts3transfer.compatRRts3transfer.exceptionsRRts3transfer.utilsRRt	getLoggerRRGtobjectRRRRRRkRxR�R�R�R�tIN_MEMORY_UPLOAD_TAGtIN_MEMORY_DOWNLOAD_TAG(((s6/usr/lib/python2.7/site-packages/s3transfer/futures.pyt<module>
s01&�L#/