
    vKgWo                     0   S SK r S SKrS SKrS SKrS SKJrJr  S SKJrJ	r	J
r
  S SKJr  S SKJr  S SKJr  S SKJrJr  S SKJrJrJrJrJrJr  S S	KJr  S S
KJrJrJ r J!r!J"r"J#r#J$r$J%r%  \RL                  " \'5      r( " S S5      r) " S S5      r* " S S5      r+g)    N)BandwidthLimiterLeakyBucket)ALLOWED_DOWNLOAD_ARGSKBMB)CopySubmissionTask)DeleteSubmissionTask)DownloadSubmissionTask)CancelledError
FatalError)IN_MEMORY_DOWNLOAD_TAGIN_MEMORY_UPLOAD_TAGBoundedExecutorTransferCoordinatorTransferFutureTransferMeta)UploadSubmissionTask)CallArgsOSUtilsSlidingWindowSemaphoreTaskSemaphoreadd_s3express_defaultsget_callbackssignal_not_transferringsignal_transferringc                   N    \ rS rSrS\-  S\-  SSSSSS\-  SSSS4S jrS	 rS
rg)TransferConfig/      
      i     Nc                     Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        Xl
        Xl        U R                  5         g)a  Configurations for the transfer manager

: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 transferring 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.

:param max_submission_queue_size: The maximum amount of
    TransferManager method calls that can be queued at a time.

:param max_io_queue_size: The maximum amount of read parts that
    can be queued to be written to disk per download. The default
    size for each elementin 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 streaming
    down the data from s3 (i.e. socket errors and read timeouts that
    occur after receiving 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 download 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)multipart_thresholdmultipart_chunksizemax_request_concurrencymax_submission_concurrencymax_request_queue_sizemax_submission_queue_sizemax_io_queue_sizeio_chunksizenum_download_attemptsmax_in_memory_upload_chunksmax_in_memory_download_chunksmax_bandwidth_validate_attrs_are_nonzero)selfr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   s                R/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/s3transfer/manager.py__init__TransferConfig.__init__0   sY    l $7 #6 '>$*D'&<#)B&!2(%:"+F(-J**((*    c                     U R                   R                  5        H"  u  pUc  M
  US::  d  M  [        SU SU S35      e   g )Nr   zProvided parameter z
 of value z must be greater than 0.)__dict__items
ValueError)r1   attrattr_vals      r2   r0   *TransferConfig._validate_attrs_are_nonzero   sL    "mm113ND#A )$z( D) )  4r5   )r+   r/   r.   r-   r*   r&   r(   r'   r)   r%   r$   r,   )	__name__
__module____qualname____firstlineno__r   r   r3   r0   __static_attributes__ r5   r2   r   r   /   s@     FF "#$#"&2X$&&(b+Hr5   r   c                      \ rS rSr\r/ SQr\/ SQ-   r/ SQrSrS\	R                  " S5      0rSS	 jr\S
 5       r\S 5       rSS jr SS jr   SS jrSS jrS rS rS r SS jrS rS rS rS rS rSS jr\4S jrSr g) TransferManager   )ACLCacheControlChecksumAlgorithmContentDispositionContentEncodingContentLanguageContentTypeExpectedBucketOwnerExpiresGrantFullControl	GrantReadGrantReadACPGrantWriteACPMetadataObjectLockLegalHoldStatusObjectLockModeObjectLockRetainUntilDateRequestPayerServerSideEncryptionStorageClassSSECustomerAlgorithmSSECustomerKeySSECustomerKeyMD5SSEKMSKeyIdSSEKMSEncryptionContextTaggingWebsiteRedirectLocation)	CopySourceIfMatchCopySourceIfModifiedSinceCopySourceIfNoneMatchCopySourceIfUnmodifiedSinceCopySourceSSECustomerAlgorithmCopySourceSSECustomerKeyCopySourceSSECustomerKeyMD5MetadataDirectiveTaggingDirective)MFA	VersionIdrW   rM   TzS3 Object LambdazV^arn:(aws).*:s3-object-lambda:[a-z\-0-9]+:[0-9]{12}:accesspoint[/:][a-zA-Z0-9\-]{1,63}Nc           
      `   Xl         X l        Uc  [        5       U l        X0l        Uc  [	        5       U l        [        5       U l        SU l        [        U R                  R                  U R                  R                  [        [        U R                  R                  5      [        [        U R                  R                   5      0US9U l        [        U R                  R$                  U R                  R&                  US9U l        [        U R                  R*                  SUS9U l        SU l        U R                  R0                  bY  [2        R5                  SU R                  R0                  5        [7        U R                  R0                  5      n[9        U5      U l        U R;                  5         g)a  A 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   )max_sizemax_num_threadstag_semaphoresexecutor_cls)rm   rn   rp      zSetting max_bandwidth to %s)_client_configr   _osutilr   TransferCoordinatorController_coordinator_controller_id_counterr   r(   r&   r   r   r-   r   r   r.   _request_executorr)   r'   _submission_executorr*   _io_executor_bandwidth_limiterr/   loggerdebugr   r   _register_handlers)r1   clientconfigosutilrp   leaky_buckets         r2   r3   TransferManager.__init__   sY    >)+DL>"9DL'D'F$ "1\\88 LL@@$mLL<<' '(>LL>>)	 &"
  %4\\;; LLCC%%
! ,\\33%
 #'<<%%1LL-t||/I/I 't||'A'ABL&6|&DD#!r5   c                     U R                   $ N)rr   r1   s    r2   r   TransferManager.client      ||r5   c                     U R                   $ r   )rs   r   s    r2   r   TransferManager.config   r   r5   c                    Uc  0 nUc  / nU R                  X@R                  5        U R                  U5        U R                  X$5        [	        UUUUUS9n0 nU R
                  (       a  U R
                  US'   U R                  U[        U5      $ )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
)fileobjbucketkey
extra_argssubscribersbandwidth_limiter)_validate_all_known_argsALLOWED_UPLOAD_ARGS_validate_if_bucket_supported_add_operation_defaultsr   r{   _submit_transferr   )r1   r   r   r   r   r   	call_argsextra_main_kwargss           r2   uploadTransferManager.upload$  s    4 JK%%j2J2JK**62$$V8!#
	 ""595L5L12$$+->
 	
r5   c                    Uc  0 nUc  / nU R                  X@R                  5        U R                  U5        [        UUUUUS9nSU R                  0nU R
                  (       a  U R
                  US'   U R                  U[        U5      $ )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
)r   r   r   r   r   io_executorr   )r   r   r   r   rz   r{   r   r
   )r1   r   r   r   r   r   r   r   s           r2   downloadTransferManager.downloadS  s    8 JK%%j2L2LM**62!#
	 +D,=,=>""595L5L12$$-/@
 	
r5   c           	      >   Uc  0 nUc  / nUc  U R                   nU R                  X@R                  5        [        U[        5      (       a   U R                  UR                  S5      5        U R                  U5        [        UUUUUUS9nU R                  U[        5      $ )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
Bucket)copy_sourcer   r   r   r   source_client)
rr   r   ALLOWED_COPY_ARGS
isinstancedictr   getr   r   r   )r1   r   r   r   r   r   r   r   s           r2   copyTransferManager.copy  s    V JK  LLM%%j2H2HIk4((..{x/HI**62#!#'
	 $$Y0BCCr5   c                     Uc  0 nUc  / nU R                  X0R                  5        U R                  U5        [        UUUUS9nU R	                  U[
        5      $ )a0  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.

)r   r   r   r   )r   ALLOWED_DELETE_ARGSr   r   r   r	   )r1   r   r   r   r   r   s         r2   deleteTransferManager.delete  sh    , JK%%j2J2JK**62!#	
	 $$Y0DEEr5   c                     U R                   (       aK  U R                  R                  5        H,  u  p#UR                  U5      nU(       d  M  [	        SU S35      e   g g )Nz'TransferManager methods do not support z+ resource. Use direct client calls instead.) VALIDATE_SUPPORTED_BUCKET_VALUES_UNSUPPORTED_BUCKET_PATTERNSr8   matchr9   )r1   r   resourcepatternr   s        r2   r   -TransferManager._validate_if_bucket_supported  sc     00%)%F%F%L%L%N!f-5$A( LE E  &O 1r5   c           	      t    U H2  nX2;  d  M
  [        SR                  USR                  U5      5      5      e   g )Nz/Invalid extra_args key '{}', must be one of: {}z, )r9   formatjoin)r1   actualallowedkwargs       r2   r   (TransferManager._validate_all_known_args  s9    E# ))/tyy7I)J  r5   c                     [        X5        g r   )r   )r1   r   r   s      r2   r   'TransferManager._add_operation_defaults  s
    v2r5   c                    U(       d  0 nU R                  U5      u  pE[        US5       H  nUS   R                  U5        M     U R                  XC5      nU R                  R                  U" US   US95        U =R                  S-  sl        U$ )Ndonecoordinator)transfer_coordinatormain_kwargsrq   )_get_future_with_componentsr   add_done_callback _get_submission_task_main_kwargsry   submitrw   )r1   r   submission_task_clsr   transfer_future
componentscallbackr   s           r2   r    TransferManager._submit_transfer  s     ! " '+&F&F'
# &ov>H}%77A ? ;;
 	!!((%/%>'	
 	Ar5   c                     U R                   n[        US9nU R                  R                  U5        UR	                  U R                  R
                  U5        [        XS9US.n[        S0 UD6nXT4$ )N)transfer_id)metar   rB   )rw   r   rv   add_transfer_coordinatorr   remove_transfer_coordinatorr   r   )r1   r   r   r   r   r   s         r2   r   +TransferManager._get_future_with_components!  s}    &&2{K$$== 	

 	..((DD 	

 !D/

 )6:6**r5   c                     U R                   U R                  U R                  U R                  US.nUR	                  U5        U$ )N)r   r   r   request_executorr   )rr   rs   rt   rx   update)r1   r   r   r   s       r2   r   0TransferManager._get_submission_task_main_kwargs6  sC     llllll $ 6 6.
 	,-r5   c                     SnU R                   R                  R                  R                  U[        SS9  U R                   R                  R                  R                  U[        SS9  g )Nzrequest-created.s3zs3upload-not-transferring)	unique_idzs3upload-transferring)rr   r   eventsregister_firstr   register_lastr   )r1   
event_names     r2   r~   "TransferManager._register_handlersC  sa    )
  //#1 	0 	

 	  ..+7N 	/ 	
r5   c                     U $ r   rB   r   s    r2   	__enter__TransferManager.__enter__O  s    r5   c                     SnSn[         nU(       a:  Sn[        U5      nU(       d  [        U5      n[        U[        5      (       a  [
        nU R                  XEU5        g )NF T)r   strreprr   KeyboardInterruptr   	_shutdown)r1   exc_type	exc_valueargscancel
cancel_msgcancel_exc_types          r2   __exit__TransferManager.__exit__R  sS    
$ FYJ!)_
 )%677"0v?;r5   c                 (    U R                  XU5        g)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   )r1   r   r   s      r2   shutdownTransferManager.shutdownc  s     	vz2r5   c                    U(       a  U R                   R                  X#5         U R                   R                  5          U R                  R                  5         U R                  R                  5         U R                  R                  5         g ! [         a    U R                   R                  S5        e f = f! U R                  R                  5         U R                  R                  5         U R                  R                  5         f = f)NzKeyboardInterrupt())rv   r   waitr   ry   r   rx   rz   )r1   r   r   r   s       r2   r   TransferManager._shutdownt  s     ((//
E	) ((--/ %%..0""++-&&( ! 	 ((//0EF	 %%..0""++-&&(s   B 'B55B8 8AD)	r{   rr   rs   rv   rw   rz   rt   rx   ry   )NNN)NNr   )Fr   )!r=   r>   r?   r@   r   r   r   r   r   recompiler   r3   propertyr   r   r   r   r   r   r   r   r   r   r   r   r~   r   r   r   r   r   rA   rB   r5   r2   rD   rD      s    1< , 
/ 
 (,$ 	BJJ2
$ @"D    -
` BF.
j =D~"FH3 AE!F+*

<"3" 6D )r5   rD   c                   J    \ rS rSrS r\S 5       rS rS rS\	4S jr
S rS	rg
)ru   i  c                 V    [         R                  " 5       U l        [        5       U l        g)zAbstraction to control all transfer coordinators

This abstraction allows the manager to wait for inprogress transfers
to complete and cancel all inprogress transfers.
N)	threadingLock_lockset_tracked_transfer_coordinatorsr   s    r2   r3   &TransferCoordinatorController.__init__  s     ^^%
.1e+r5   c                     U R                      [        R                  " U R                  5      sSSS5        $ ! , (       d  f       g= f)z.The set of transfer coordinators being trackedN)r   r   r   r   s    r2   tracked_transfer_coordinators;TransferCoordinatorController.tracked_transfer_coordinators  s)     ZZ 99T@@A	 ZZs	    7
Ac                     U R                      U R                  R                  U5        SSS5        g! , (       d  f       g= f)zAdds 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   addr1   r   s     r2   r   6TransferCoordinatorController.add_transfer_coordinator  s*     ZZ//334HI ZZ	   2
A c                     U R                      U R                  R                  U5        SSS5        g! , (       d  f       g= f)aQ  Remove a transfer coordinator from cancellation 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   remover  s     r2   r   9TransferCoordinatorController.remove_transfer_coordinator  s*     ZZ//667KL ZZr  r   c                 L    U R                    H  nUR                  X5        M     g)a   Cancels 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   )r1   msgr   r   s       r2   r   $TransferCoordinatorController.cancel  s$     %)$F$F  ''6 %Gr5   c                      SnU R                    H  nUR                  5         M     g! [         a4    [        R	                  S5        W(       a  [        R	                  SU5        e [
         a     gf = f)zWait until there are no more inprogress transfers

This will not stop when failures are encountered and not propagate 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   resultr   r|   r}   	Exceptionr  s     r2   r   "TransferCoordinatorController.wait  sp    	#' (,(J(J$$++- )K  
	LL?@ $=(  	
 	s   %( AA10A1)r   r   N)r=   r>   r?   r@   r3   r   r   r   r   r   r   r   rA   rB   r5   r2   ru   ru     s:    4 B BJM n 7r5   ru   ),r   loggingr   r   s3transfer.bandwidthr   r   s3transfer.constantsr   r   r   s3transfer.copiesr   s3transfer.deleter	   s3transfer.downloadr
   s3transfer.exceptionsr   r   s3transfer.futuresr   r   r   r   r   r   s3transfer.uploadr   s3transfer.utilsr   r   r   r   r   r   r   r   	getLoggerr=   r|   r   rD   ru   rB   r5   r2   <module>r     s~      	  > > > 0 2 6 <  3	 	 	 
		8	$k k\m) m)`S Sr5   