Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/s3transfer/__pycache__/futures.cpython-37.pyc

218 lines
21 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>[<5B>]<5D>R<00>@sBddlmZddlmZddlZddlZddlZddlZddlm Z ddlm
Z
ddl m Z m Z ddlmZddlmZe<05>e<12>ZGd d
<EFBFBD>d
e<14>ZGd d <0C>d e<14>ZGd d<0E>de<15>ZGdd<10>de<16>ZGdd<12>de<14>ZGdd<14>de<14>ZGdd<16>de<14>ZGdd<18>de<14>ZGdd<1A>de<1C>ZGdd<1C>de<14>Zeddg<01>Zed<1F>Z ed <20>Z!dS)!<21>)<01>futures)<01>
namedtupleN)<01>MAXINT)<01>six)<02>CancelledError<6F>TransferNotDoneError)<01>FunctionContainer)<01> TaskSemaphorec@s0eZdZedd<02><00>Zdd<04>Zdd<06>Zdd<08>Zd S)
<EFBFBD>BaseTransferFuturecCs td<01><01>dS)z-The metadata associated to the TransferFuture<72>metaN)<01>NotImplementedError)<01>self<6C>r<00>:/tmp/pip-install-u_6_z2pz/s3transfer/s3transfer/futures.pyr szBaseTransferFuture.metacCs td<01><01>dS)zmDetermines if a TransferFuture has completed
:returns: True if completed. False, otherwise.
zdone()N)r )r rrr<00>done$szBaseTransferFuture.donecCs td<01><01>dS)z<>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.
zresult()N)r )r rrr<00>result+szBaseTransferFuture.resultcCs td<01><01>dS)z6Cancels the request associated with the TransferFuturezcancel()N)r )r rrr<00>cancel4szBaseTransferFuture.cancelN)<08>__name__<5F>
__module__<EFBFBD> __qualname__<5F>propertyr rrrrrrrr
s  r
c@s0eZdZedd<02><00>Zedd<04><00>Zedd<06><00>ZdS)<08>BaseTransferMetacCs td<01><01>dS)z*The call args used in the transfer request<73> call_argsN)r )r rrrr:szBaseTransferMeta.call_argscCs td<01><01>dS)zThe unique id of the transfer<65> transfer_idN)r )r rrrr?szBaseTransferMeta.transfer_idcCs td<01><01>dS)z.A dictionary that requesters can store data in<69> user_contextN)r )r rrrrDszBaseTransferMeta.user_contextN)rrrrrrrrrrrr9s  rc@sBeZdZddd<03>Zedd<05><00>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z dS)<0F>TransferFutureNcCs0||_|dkrt<01>|_||_|dkr,t<03>|_dS)a<>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)<04>_meta<74> TransferMeta<74> _coordinator<6F>TransferCoordinator)r r Z coordinatorrrr<00>__init__Ks zTransferFuture.__init__cCs|jS)N)r)r rrrr ^szTransferFuture.metacCs
|j<00><01>S)N)rr)r rrrrbszTransferFuture.donec
Cs>y
|j<00><01>Stk
r8}z|<00><03>|<01>Wdd}~XYnXdS)N)rr<00>KeyboardInterruptr)r <00>errrres

zTransferFuture.resultcCs|j<00><01>dS)N)rr)r rrrroszTransferFuture.cancelcCs$|<00><00>std<01><01>|jj|dd<03>dS)z!Sets the exception on the future.z?set_exception can only be called once the transfer is complete.T)<01>overrideN)rrr<00> set_exception)r <00> exceptionrrrr$rszTransferFuture.set_exception)NN)
rrrr rr rrrr$rrrrrJs 
 
rc@sReZdZdZddd<04>Zedd<06><00>Zedd<08><00>Zed d
<EFBFBD><00>Zed d <0C><00>Z d d<0E>Z
dS)rz'Holds metadata about the TransferFutureNcCs||_||_d|_i|_dS)N)<04>
_call_args<EFBFBD> _transfer_id<69>_size<7A> _user_context)r rrrrrr }szTransferMeta.__init__cCs|jS)z*The call args used in the transfer request)r&)r rrrr<00>szTransferMeta.call_argscCs|jS)zThe unique id of the transfer)r')r rrrr<00>szTransferMeta.transfer_idcCs|jS)z)The size of the transfer request if known)r()r rrr<00>size<7A>szTransferMeta.sizecCs|jS)z.A dictionary that requesters can store data in)r))r rrrr<00>szTransferMeta.user_contextcCs
||_dS)z<>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()r r*rrr<00>provide_transfer_size<7A>sz"TransferMeta.provide_transfer_size)NN) rrr<00>__doc__r rrrr*rr+rrrrr{s
    rc@s<>eZdZdZd5dd<04>Zdd<06>Zedd<08><00>Zed d
<EFBFBD><00>Zed d <0C><00>Z ed d<0E><00>Z
dd<10>Z d6dd<13>Z dd<15>Z defdd<18>Zdd<1A>Zdd<1C>Zdd<1E>Zd7dd <20>Zd!d"<22>Zd#d$<24>Zd%d&<26>Zd'd(<28>Zd)d*<2A>Zd+d,<2C>Zd-d.<2E>Zd/d0<64>Zd1d2<64>Zd3d4<64>ZdS)8rz*A helper class for managing TransferFutureNcCsb||_d|_d|_d|_t<04>|_g|_g|_t<08> <09>|_
t<08> <0B>|_ t<08> <0B>|_ t<08> <0B>|_t<08> <0B>|_dS)Nz not-started)r<00>_status<75>_result<6C>
_exception<EFBFBD>set<65>_associated_futures<65>_failure_cleanups<70>_done_callbacks<6B> threading<6E>Event<6E> _done_event<6E>Lock<63>_lock<63>_associated_futures_lock<63>_done_callbacks_lock<63>_failure_cleanups_lock)r rrrrr <00>s



zTransferCoordinator.__init__cCsd|jj|jfS)Nz%s(transfer_id=%s))<03> __class__rr)r rrr<00>__repr__<5F>szTransferCoordinator.__repr__cCs|jS)N)r/)r rrrr%<00>szTransferCoordinator.exceptionc Cs|j<00>t<01>|j<02>SQRXdS)z<>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)r9<00>copyr1)r rrr<00>associated_futures<65>sz&TransferCoordinator.associated_futurescCs|jS)z;The list of callbacks to call when the TransferFuture fails)r2)r rrr<00>failure_cleanups<70>sz$TransferCoordinator.failure_cleanupscCs|jS)a<>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 rrr<00>status<75>szTransferCoordinator.statusc Cs(|j<00>d|_||_d|_WdQRXdS)a<>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.
N<>success)r8r/r.r-)r rrrr<00>
set_result<EFBFBD>s
zTransferCoordinator.set_resultFc Cs.|j<00>|<00><01>r|r ||_d|_WdQRXdS)z<>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.
<20>failedN)r8rr/r-)r r%r#rrrr$<00>s z!TransferCoordinator.set_exceptioncCs|j<00>t<02>|jr|j<03>|jS)z<>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.
)r6<00>waitrr/r.)r rrrr<00>s zTransferCoordinator.result<6C>c CsZ|j<00>J|<00><01>sLd}t<02>d||<01>||<01>|_|jdkr:d}d|_|rL|<00><06>WdQRXdS)z<>Cancels the TransferFuture
:param msg: The message to attach to the cancellation
:param exc_type: The type of exception to set for the cancellation
Fz%s cancel(%s) calledz not-startedT<64> cancelledN)r8r<00>logger<65>debugr/r-<00> announce_done)r <00>msg<73>exc_typeZshould_announce_donerrrr s

zTransferCoordinator.cancelcCs|<00>d<01>dS)z+Sets the TransferFutrue's status to runningZqueuedN)<01>_transition_to_non_done_state)r rrr<00>set_status_to_queuedsz(TransferCoordinator.set_status_to_queuedcCs|<00>d<01>dS)z+Sets the TransferFuture's status to runningZrunningN)rM)r rrr<00>set_status_to_running!sz)TransferCoordinator.set_status_to_runningc Cs6|j<00>&|<00><01>r"td|j|f<00><01>||_WdQRXdS)Nz=Unable to transition from done state %s to non-done state %s.)r8r<00> RuntimeErrorrAr-)r Z desired_staterrrrM%s z1TransferCoordinator._transition_to_non_done_statecCsDt<00>d|||jf<00>|j||d<02>}|<00>|<04>|<04>t|j|<04><02>|S)a<>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
z;Submitting task %s to executor %s for transfer request: %s.)<01>tag)rHrIr<00>submit<69>add_associated_future<72>add_done_callbackr<00>remove_associated_future)r <00>executor<6F>taskrQ<00>futurerrrrR-s
zTransferCoordinator.submitcCs
|jdkS)z<>Determines if a TransferFuture has completed
:returns: False if status is equal to 'failed', 'cancelled', or
'success'. True, otherwise
)rDrGrB)rA)r rrrrHszTransferCoordinator.donec Cs"|j<00>|j<01>|<01>WdQRXdS)z6Adds a future to be associated with the TransferFutureN)r9r1<00>add)r rXrrrrSPsz)TransferCoordinator.add_associated_futurec Cs"|j<00>|j<01>|<01>WdQRXdS)z4Removes a future's association to the TransferFutureN)r9r1<00>remove)r rXrrrrUUsz,TransferCoordinator.remove_associated_futurec Os.|j<00>|j<01>t|f|<02>|<03><01>WdQRXdS)z7Add a done callback to be invoked when transfer is doneN)r:r3<00>appendr)r <00>function<6F>args<67>kwargsrrrrTZsz%TransferCoordinator.add_done_callbackc Os.|j<00>|j<01>t|f|<02>|<03><01>WdQRXdS)z$Adds a callback to call upon failureN)r;r2r[r)r r\r]r^rrr<00>add_failure_cleanupasz'TransferCoordinator.add_failure_cleanupcCs(|jdkr|<00><01>|j<02><03>|<00><04>dS)aMAnnounce 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.
rBN)rA<00>_run_failure_cleanupsr6r0<00>_run_done_callbacks)r rrrrJgs

z!TransferCoordinator.announce_donec Cs(|j<00>|<00>|j<02>g|_WdQRXdS)N)r:<00>_run_callbacksr3)r rrrrats z'TransferCoordinator._run_done_callbacksc Cs(|j<00>|<00>|j<02>g|_WdQRXdS)N)r;rbr@r2)r rrrr`|s z)TransferCoordinator._run_failure_cleanupscCsx|D]}|<00>|<02>qWdS)N)<01> _run_callback)r <00> callbacks<6B>callbackrrrrb<00>s
z"TransferCoordinator._run_callbackscCs6y
|<01>Wn&tk
r0tjd|dd<03>YnXdS)NzException raised in %s.T)<01>exc_info)<03> ExceptionrHrI)r rerrrrc<00>s
z!TransferCoordinator._run_callback)N)F)N)rrrr,r r=rr%r?r@rArCr$rrrrNrOrMrRrrSrUrTr_rJrar`rbrcrrrrr<00>s2
   

 rc@s0eZdZejZd dd<03>Zd
dd<06>Zd dd<08>ZdS) <0C>BoundedExecutorNcCs6||_|dkr|j}||jd<02>|_t|<01>|_||_dS)aDAn 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.
N)<01> max_workers)Z_max_num_threads<64> EXECUTOR_CLS<4C> _executorr <00>
_semaphore<EFBFBD>_tag_semaphores)r <00>max_sizeZmax_num_threadsZtag_semaphoresZ executor_clsrrrr <00>s 
zBoundedExecutor.__init__TcCsP|j}|r|j|}|<04>|j|<03>}t|j|j|<05>}t|j<07>|<01><01>}|<07> |<06>|S)a1Submit 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
)
rlrm<00>acquirerr<00>release<73>ExecutorFuturerkrRrT)r rWrQ<00>blockZ semaphoreZ acquire_tokenZrelease_callbackrXrrrrR<00>s

zBoundedExecutor.submitcCs|j<00>|<01>dS)N)rk<00>shutdown)r rErrrrs<00>szBoundedExecutor.shutdown)NN)NT)T) rrrrZThreadPoolExecutorrjr rRrsrrrrrh<00>s


%rhc@s,eZdZdd<02>Zdd<04>Zdd<06>Zdd<08>Zd S)
rqcCs
||_dS)a<>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)<01>_future)r rXrrrr <00>s zExecutorFuture.__init__cCs
|j<00><01>S)N)rtr)r rrrr<00>szExecutorFuture.resultcs<00>fdd<02>}|j<00>|<02>dS)aAdds 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<00><00>S)Nr)Zfuture_passed_to_callback)<01>fnrr<00> done_callback<63>sz7ExecutorFuture.add_done_callback.<locals>.done_callbackN)rtrT)r rurvr)rurrT<00>s
z ExecutorFuture.add_done_callbackcCs
|j<00><01>S)N)rtr)r rrrr<00>szExecutorFuture.doneN)rrrr rrTrrrrrrq<00>s rqc@s,eZdZdZd
dd<04>Zdd<06>Zd dd <09>ZdS) <0C> BaseExecutorzABase Executor class implementation needed to work with s3transferNcCsdS)Nr)r rirrrr szBaseExecutor.__init__cOs td<01><01>dS)Nzsubmit())r )r rur]r^rrrrRszBaseExecutor.submitTcCs td<01><01>dS)Nz
shutdown())r )r rErrrrsszBaseExecutor.shutdown)N)T)rrrr,r rRrsrrrrrws
rwc@s"eZdZdZdd<03>Zddd<06>ZdS) <09>NonThreadedExecutorz@A drop-in replacement non-threaded version of ThreadPoolExecutorc Osht<00>}y|||<03>}|<04>|<05>WnDtk
rbt<03><04>dd<00>\}}t<05>d|||<07>|<04>||<07>YnX|S)N<>z0Setting exception for %s to %s with traceback %s)<08>NonThreadedExecutorFuturerCrg<00>sysrfrHrI<00>set_exception_info)r rur]r^rXrr"<00>tbrrrrRs

zNonThreadedExecutor.submitTcCsdS)Nr)r rErrrrsszNonThreadedExecutor.shutdownN)T)rrrr,rRrsrrrrrx srxc@sReZdZdZdd<03>Zdd<05>Zdd<07>Zdd d
<EFBFBD>Zd d <0C>Zd d<0E>Z dd<10>Z
dd<12>Z dS)rzz<>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.
cCs"d|_d|_d|_d|_g|_dS)NF)r.r/<00>
_traceback<EFBFBD>_doner3)r rrrr &s
z"NonThreadedExecutorFuture.__init__cCs||_|<00><01>dS)N)r.<00> _set_done)r rrrrrC-sz$NonThreadedExecutorFuture.set_resultcCs||_||_|<00><02>dS)N)r/r~r<>)r r%<00> tracebackrrrr|1sz,NonThreadedExecutorFuture.set_exception_infoNcCs$|jrt<01>t|j<00>|j|j<04>|jS)N)r/r<00>reraise<73>typer~r.)r <00>timeoutrrrr6sz NonThreadedExecutorFuture.resultcCs*d|_x|jD]}|<00>|<01>qWg|_dS)NT)rr3<00>_invoke_done_callback)r rvrrrr<><s z#NonThreadedExecutorFuture._set_donecCs||<00>S)Nr)r rvrrrr<>Bsz/NonThreadedExecutorFuture._invoke_done_callbackcCs|jS)N)r)r rrrrEszNonThreadedExecutorFuture.donecCs"|jr|<00>|<01>n |j<02>|<01>dS)N)rr<>r3r[)r rurrrrTHs z+NonThreadedExecutorFuture.add_done_callback)N) rrrr,r rCr|rr<>r<>rrTrrrrrz s
rz<00>TaskTag<61>nameZin_memory_uploadZin_memory_download)"Z
concurrentr<00> collectionsrr><00>loggingr{r4Zs3transfer.compatrrZs3transfer.exceptionsrrZs3transfer.utilsrr <00> getLoggerrrH<00>objectr
rrrrrhrqrwrxrzr<>ZIN_MEMORY_UPLOAD_TAGZIN_MEMORY_DOWNLOAD_TAGrrrr<00><module> s2      
1&qL# /