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

291 lines
20 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>[<5B>]<5D>i<00>@szddlZddlZddlZddlmZddlmZmZddlmZddl m
Z
ddl m Z ddl m Z ddl m Z dd l mZdd
l mZdd l mZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl#m%Z%e<01>&e'<27>Z(Gdd<1B>de)<29>Z*Gdd<1D>de)<29>Z+Gdd<1F>de)<29>Z,dS) <20>N)<01>six)<02>KB<4B>MB)<01>ALLOWED_DOWNLOAD_ARGS)<01> get_callbacks)<01>signal_transferring)<01>signal_not_transferring)<01>CallArgs)<01>OSUtils)<01> TaskSemaphore)<01>SlidingWindowSemaphore)<01>CancelledError)<01>
FatalError)<01>IN_MEMORY_DOWNLOAD_TAG)<01>IN_MEMORY_UPLOAD_TAG)<01>BoundedExecutor)<01>TransferFuture)<01> TransferMeta)<01>TransferCoordinator)<01>DownloadSubmissionTask)<01>UploadSubmissionTask)<01>CopySubmissionTask)<01>DeleteSubmissionTask)<01> LeakyBucket)<01>BandwidthLimiterc @sBeZdZdededdddddeddddf dd<08>Zd d
<EFBFBD>ZdS) <0B>TransferConfig<69><00>
<00>i<><00>Nc CsT||_||_||_||_||_||_||_||_| |_|
|_ | |_
| |_ |<00> <0C>dS)a(Configurations for the transfer mangager
:param multipart_threshold: The threshold for which multipart
transfers occur.
:param max_request_concurrency: The maximum number of S3 API
transfer-related requests that can happen at a time.
:param max_submission_concurrency: The maximum number of threads
processing a call to a TransferManager method. Processing a
call usually entails determining which S3 API requests that need
to be enqueued, but does **not** entail making any of the
S3 API data transfering requests needed to perform the transfer.
The threads controlled by ``max_request_concurrency`` is
responsible for that.
:param multipart_chunksize: The size of each transfer if a request
becomes a multipart transfer.
:param max_request_queue_size: The maximum amount of S3 API requests
that can be queued at a time. A value of zero means that there
is no maximum.
:param max_submission_queue_size: The maximum amount of
TransferManager method calls that can be queued at a time. A value
of zero means that there is no maximum.
:param max_io_queue_size: The maximum amount of read parts that
can be queued to be written to disk per download. A value of zero
means that there is no maximum. The default size for each element
in this queue is 8 KB.
:param io_chunksize: The max size of each chunk in the io queue.
Currently, this is size used when reading from the downloaded
stream as well.
:param num_download_attempts: The number of download attempts that
will be tried upon errors with downloading an object in S3. Note
that these retries account for errors that occur when streamming
down the data from s3 (i.e. socket errors and read timeouts that
occur after recieving an OK response from s3).
Other retryable exceptions such as throttling errors and 5xx errors
are already retried by botocore (this default is 5). The
``num_download_attempts`` does not take into account the
number of exceptions retried by botocore.
:param max_in_memory_upload_chunks: The number of chunks that can
be stored in memory at a time for all ongoing upload requests.
This pertains to chunks of data that need to be stored in memory
during an upload if the data is sourced from a file-like object.
The total maximum memory footprint due to a in-memory upload
chunks is roughly equal to:
max_in_memory_upload_chunks * multipart_chunksize
+ max_submission_concurrency * multipart_chunksize
``max_submission_concurrency`` has an affect on this value because
for each thread pulling data off of a file-like object, they may
be waiting with a single read chunk to be submitted for upload
because the ``max_in_memory_upload_chunks`` value has been reached
by the threads making the upload request.
:param max_in_memory_download_chunks: The number of chunks that can
be buffered in memory and **not** in the io queue at a time for all
ongoing dowload requests. This pertains specifically to file-like
objects that cannot be seeked. The total maximum memory footprint
due to a in-memory download chunks is roughly equal to:
max_in_memory_download_chunks * multipart_chunksize
:param max_bandwidth: The maximum bandwidth that will be consumed
in uploading and downloading file content. The value is in terms of
bytes per second.
N) <0A>multipart_threshold<6C>multipart_chunksize<7A>max_request_concurrency<63>max_submission_concurrency<63>max_request_queue_size<7A>max_submission_queue_size<7A>max_io_queue_size<7A> io_chunksize<7A>num_download_attempts<74>max_in_memory_upload_chunks<6B>max_in_memory_download_chunks<6B> max_bandwidth<74>_validate_attrs_are_nonzero) <0A>selfr r!r"r#r$r%r&r'r(r)r*r+<00>r.<00>:/tmp/pip-install-u_6_z2pz/s3transfer/s3transfer/manager.py<70>__init__0sWzTransferConfig.__init__cCs<x6|j<00><01>D](\}}|dk r |dkr td||f<00><01>q WdS)Nrz9Provided parameter %s of value %s must be greater than 0.)<03>__dict__<5F>items<6D>
ValueError)r-<00>attrZattr_valr.r.r/r,<00>s
z*TransferConfig._validate_attrs_are_nonzero)<07>__name__<5F>
__module__<EFBFBD> __qualname__rrr0r,r.r.r.r/r/s Yrc@s<>eZdZeZddddddddd d
d d d dddddddgZeddddddddgZddd gZd>d d!<21>Zd?d"d#<23>Zd@d$d%<25>Z dAd&d'<27>Z
dBd(d)<29>Z d*d+<2B>Z dCd,d-<2D>Z d.d/<2F>Zd0d1<64>Zd2d3<64>Zd4d5<64>Zd6d7<64>ZdDd:d;<3B>Zefd<d=<3D>ZdS)E<>TransferManagerZACL<43> CacheControlZContentDispositionZContentEncodingZContentLanguageZ ContentTypeZExpiresZGrantFullControlZ GrantReadZ GrantReadACPZ GrantWriteACPZMetadataZ RequestPayerZServerSideEncryptionZ StorageClassZSSECustomerAlgorithmZSSECustomerKeyZSSECustomerKeyMD5Z SSEKMSKeyIdZWebsiteRedirectLocationZCopySourceIfMatchZCopySourceIfModifiedSinceZCopySourceIfNoneMatchZCopySourceIfUnmodifiedSinceZCopySourceSSECustomerAlgorithmZCopySourceSSECustomerKeyZCopySourceSSECustomerKeyMD5ZMetadataDirectiveZMFAZ VersionIdNcCs<>||_||_|dkrt<02>|_||_|dkr2t<04>|_t<05>|_d|_t|jj |jj
t t |jj <0A>tt|jj<10>i|d<03>|_t|jj|jj|d<04>|_t|jjd|d<04>|_d|_|jjdk r<>t<19>d|jj<18>t|jj<18>}t|<05>|_|<00><1D>dS)aA transfer manager interface for Amazon S3
:param client: Client to be used by the manager
:param config: TransferConfig to associate specific configurations
:param osutil: OSUtils object to use for os-related behavior when
using with transfer manager.
:type executor_cls: s3transfer.futures.BaseExecutor
:param executor_cls: The class of executor to use with the transfer
manager. By default, concurrent.futures.ThreadPoolExecutor is used.
Nr)<04>max_size<7A>max_num_threadsZtag_semaphores<65> executor_cls)r:r;r<<00>zSetting max_bandwidth to %s)<1E>_client<6E>_configr<00>_osutilr
<00>TransferCoordinatorController<65>_coordinator_controller<65> _id_counterrr$r"rr r)rr r*<00>_request_executorr%r#<00>_submission_executorr&<00> _io_executor<6F>_bandwidth_limiterr+<00>logger<65>debugrr<00>_register_handlers)r-<00>client<6E>config<69>osutilr<Z leaky_bucketr.r.r/r0<00>s@ 



   
zTransferManager.__init__cCsZ|dkr i}|dkrg}|<00>||j<01>t|||||d<02>}i}|jrL|j|d<|<00>|t|<07>S)a<>Uploads a file to S3
:type fileobj: str or seekable file-like object
:param fileobj: The name of a file to upload or a seekable file-like
object to upload. It is recommended to use a filename because
file-like objects may result in higher memory usage.
:type bucket: str
:param bucket: The name of the bucket to upload to
:type key: str
:param key: The name of the key to upload to
:type extra_args: dict
:param extra_args: Extra arguments that may be passed to the
client operation
:type subscribers: list(s3transfer.subscribers.BaseSubscriber)
:param subscribers: The list of subscribers to be invoked in the
order provided based on the event emit during the process of
the transfer request.
:rtype: s3transfer.futures.TransferFuture
:returns: Transfer future representing the upload
N)<05>fileobj<62>bucket<65>key<65>
extra_args<EFBFBD> subscribers<72>bandwidth_limiter)<06>_validate_all_known_args<67>ALLOWED_UPLOAD_ARGSr rG<00>_submit_transferr)r-rNrOrPrQrR<00> call_args<67>extra_main_kwargsr.r.r/<00>uploads
zTransferManager.uploadcCs`|dkr i}|dkrg}|<00>||j<01>t|||||d<02>}d|ji}|jrR|j|d<|<00>|t|<07>S)a<>Downloads a file from S3
:type bucket: str
:param bucket: The name of the bucket to download from
:type key: str
:param key: The name of the key to download from
:type fileobj: str or seekable file-like object
:param fileobj: The name of a file to download or a seekable file-like
object to download. It is recommended to use a filename because
file-like objects may result in higher memory usage.
:type extra_args: dict
:param extra_args: Extra arguments that may be passed to the
client operation
:type subscribers: list(s3transfer.subscribers.BaseSubscriber)
:param subscribers: The list of subscribers to be invoked in the
order provided based on the event emit during the process of
the transfer request.
:rtype: s3transfer.futures.TransferFuture
:returns: Transfer future representing the download
N)rOrPrNrQrRZ io_executorrS)rTrr rFrGrVr)r-rOrPrNrQrRrWrXr.r.r/<00>download1s

zTransferManager.downloadcCsT|dkr i}|dkrg}|dkr&|j}|<00>||j<02>t||||||d<02>}|<00>|t<05>S)a<>Copies a file in S3
:type copy_source: dict
:param copy_source: The name of the source bucket, key name of the
source object, and optional version ID of the source object. The
dictionary format is:
``{'Bucket': 'bucket', 'Key': 'key', 'VersionId': 'id'}``. Note
that the ``VersionId`` key is optional and may be omitted.
:type bucket: str
:param bucket: The name of the bucket to copy to
:type key: str
:param key: The name of the key to copy to
:type extra_args: dict
:param extra_args: Extra arguments that may be passed to the
client operation
:type subscribers: a list of subscribers
:param subscribers: The list of subscribers to be invoked in the
order provided based on the event emit during the process of
the transfer request.
:type source_client: botocore or boto3 Client
:param source_client: The client to be used for operation that
may happen at the source object. For example, this client is
used for the head_object that determines the size of the copy.
If no client is provided, the transfer manager's client is used
as the client for the source object.
:rtype: s3transfer.futures.TransferFuture
:returns: Transfer future representing the copy
N)<06> copy_sourcerOrPrQrR<00> source_client)r>rT<00>ALLOWED_COPY_ARGSr rVr)r-r[rOrPrQrRr\rWr.r.r/<00>copy[s$zTransferManager.copycCsB|dkr i}|dkrg}|<00>||j<01>t||||d<02>}|<00>|t<04>S)a<>Delete an S3 object.
:type bucket: str
:param bucket: The name of the bucket.
:type key: str
:param key: The name of the S3 object to delete.
:type extra_args: dict
:param extra_args: Extra arguments that may be passed to the
DeleteObject call.
:type subscribers: list
:param subscribers: A list of subscribers to be invoked during the
process of the transfer request. Note that the ``on_progress``
callback is not invoked during object deletion.
:rtype: s3transfer.futures.TransferFuture
:return: Transfer future representing the deletion.
N)rOrPrQrR)rT<00>ALLOWED_DELETE_ARGSr rVr)r-rOrPrQrRrWr.r.r/<00>delete<74>szTransferManager.deletecCs0x*|D]"}||krtd|d<02>|<02>f<00><01>qWdS)Nz/Invalid extra_args key '%s', must be one of: %sz, )r3<00>join)r-<00>actual<61>allowed<65>kwargr.r.r/rT<00>s

z(TransferManager._validate_all_known_argscCsn|si}|<00>|<01>\}}x t|d<01>D]}|d<00>|<06>q"W|<00>||<03>}|j<04>||d|d<03><02>|jd7_|S)N<>done<6E> coordinator)<02>transfer_coordinator<6F> main_kwargsr=)<07>_get_future_with_componentsr<00>add_done_callback<63> _get_submission_task_main_kwargsrEZsubmitrC)r-rWZsubmission_task_clsrX<00>transfer_future<72>
components<EFBFBD>callbackrhr.r.r/rV<00>s

z TransferManager._submit_transfercCsP|j}t|d<01>}|j<02>|<03>|<03>|jj|<03>t||d<01>|d<02>}tf|<04>}||fS)N)<01> transfer_id)<02>metarf)rCrrB<00>add_transfer_coordinatorrj<00>remove_transfer_coordinatorrr)r-rWrorgrmrlr.r.r/ri<00>s


z+TransferManager._get_future_with_componentscCs&|j|j|j|j|d<01>}|<03>|<02>|S)N)rKrLrMZrequest_executorrl)r>r?r@rD<00>update)r-rlrXrhr.r.r/rk<00>s
z0TransferManager._get_submission_task_main_kwargscCs4d}|jjjj|tdd<03>|jjjj|tdd<03>dS)Nzrequest-created.s3zs3upload-not-transferring)Z unique_idzs3upload-transferring)r>rp<00>eventsZregister_firstrZ register_lastr)r-Z
event_namer.r.r/rJ<00>s

z"TransferManager._register_handlerscCs|S)Nr.)r-r.r.r/<00> __enter__<5F>szTransferManager.__enter__cGsJd}d}t}|r8d}t<01>|<02>}|s*t|<02>}t|t<05>r8t}|<00>|||<06>dS)NF<4E>T)rr<00> text_type<70>repr<70>
isinstance<EFBFBD>KeyboardInterruptr <00> _shutdown)r-<00>exc_type<70> exc_value<75>args<67>cancel<65>
cancel_msgZcancel_exc_typer.r.r/<00>__exit__s

zTransferManager.__exit__FrvcCs|<00>|||<02>dS)a<>Shutdown the TransferManager
It will wait till all transfers complete before it completely shuts
down.
:type cancel: boolean
:param cancel: If True, calls TransferFuture.cancel() for
all in-progress in transfers. This is useful if you want the
shutdown to happen quicker.
:type cancel_msg: str
:param cancel_msg: The message to specify if canceling all in-progress
transfers.
N)r{)r-rr<>r.r.r/<00>shutdownszTransferManager.shutdowncCsn|r|j<00>||<03>z6y|j<00><02>Wn"tk
rD|j<00>d<01><00>YnXWd|j<04><05>|j<06><05>|j<07><05>XdS)NzKeyboardInterrupt())rBr<00>waitrzrEr<>rDrF)r-rr<>r|r.r.r/r{$s  

zTransferManager._shutdown)NNN)NN)NN)NNN)NN)N)Frv)r5r6r7rrUr]r_r0rYrZr^r`rTrVrirkrJrur<>r<>r r{r.r.r.r/r8<00>sb
@
)
)
1
!
 

r8c@sFeZdZdd<02>Zedd<04><00>Zdd<06>Zdd<08>Zd efd
d <0B>Z d d <0A>Z
dS)rAcCst<00><01>|_t<03>|_dS)z<>Abstraction to control all transfer coordinators
This abstraction allows the manager to wait for inprogress transfers
to complete and cancel all inprogress transfers.
N)<05> threading<6E>Lock<63>_lock<63>set<65>_tracked_transfer_coordinators)r-r.r.r/r0>s
z&TransferCoordinatorController.__init__c Cs|j<00>t<01>|j<02>SQRXdS)z.The set of transfer coordinators being trackedN)r<>r^r<>)r-r.r.r/<00>tracked_transfer_coordinatorsGsz;TransferCoordinatorController.tracked_transfer_coordinatorsc Cs"|j<00>|j<01>|<01>WdQRXdS)z<>Adds a transfer coordinator of a transfer to be canceled if needed
:type transfer_coordinator: s3transfer.futures.TransferCoordinator
:param transfer_coordinator: The transfer coordinator for the
particular transfer
N)r<>r<><00>add)r-rgr.r.r/rqPsz6TransferCoordinatorController.add_transfer_coordinatorc Cs"|j<00>|j<01>|<01>WdQRXdS)a<>Remove a transfer coordinator from cancelation consideration
Typically, this method is invoked by the transfer coordinator itself
to remove its self when it completes its transfer.
:type transfer_coordinator: s3transfer.futures.TransferCoordinator
:param transfer_coordinator: The transfer coordinator for the
particular transfer
N)r<>r<><00>remove)r-rgr.r.r/rrZs
z9TransferCoordinatorController.remove_transfer_coordinatorrvcCs x|jD]}|<03>||<02>qWdS)aPCancels all inprogress transfers
This cancels the inprogress transfers by calling cancel() on all
tracked transfer coordinators.
:param msg: The message to pass on to each transfer coordinator that
gets cancelled.
:param exc_type: The type of exception to set for the cancellation
N)r<>r)r-<00>msgr|rgr.r.r/rgs z$TransferCoordinatorController.cancelcCshy d}x|jD] }|<01><01>qWWnBtk
rPt<03>d<02>|rJt<03>d|<01><00>Yntk
rbYnXdS)z<>Wait until there are no more inprogress transfers
This will not stop when failures are encountered and not propogate any
of these errors from failed transfers, but it can be interrupted with
a KeyboardInterrupt.
Nz$Received KeyboardInterrupt in wait()z'On KeyboardInterrupt was waiting for %s)r<><00>resultrzrHrI<00> Exception)r-rgr.r.r/r<>us 
z"TransferCoordinatorController.waitN) r5r6r7r0<00>propertyr<79>rqrrr rr<>r.r.r.r/rA=s  
 rA)-r^<00>loggingr<67>Zbotocore.compatrZs3transfer.constantsrrrZs3transfer.utilsrrrr r
r r Zs3transfer.exceptionsr rZs3transfer.futuresrrrrrrZs3transfer.downloadrZs3transfer.uploadrZs3transfer.copiesrZs3transfer.deleterZs3transfer.bandwidthrr<00> getLoggerr5rH<00>objectrr8rAr.r.r.r/<00><module> sB                       
n#