
    vKg?                         S SK r S SKrS SKJr  \R                  " \5      r " S S5      r " S S\5      r " S S\5      r	 " S	 S
\5      r
g)    N)get_callbacksc                   v    \ rS rSrSr    SS jrS r\S 5       rS r	S r
S	 rS
 rS rS rS rS rS rSrg)Task   zA task associated to a TransferFuture request

This is a base class for other classes to subclass from. All subclassed
classes must implement the main() method.
Nc                     Xl         X l        U R                  c  0 U l        X0l        Uc  0 U l        X@l        U R                  c  / U l        XPl        g)a  
:type transfer_coordinator: s3transfer.futures.TransferCoordinator
:param transfer_coordinator: The context associated to the
    TransferFuture for which this Task is associated with.

:type main_kwargs: dict
:param main_kwargs: The keyword args that can be immediately supplied
    to the _main() method of the task

:type pending_main_kwargs: dict
:param pending_main_kwargs: The keyword args that are depended upon
    by the result from a dependent future(s). The result returned by
    the future(s) will be used as the value for the keyword argument
    when _main() is called. The values for each key can be:
        * a single future - Once completed, its value will be the
          result of that single future
        * a list of futures - Once all of the futures complete, the
          value used will be a list of each completed future result
          value in order of when they were originally supplied.

:type done_callbacks: list of callbacks
:param done_callbacks: A list of callbacks to call once the task is
    done completing. Each callback will be called with no arguments
    and will be called no matter if the task succeeds or an exception
    is raised.

:type is_final: boolean
:param is_final: True, to indicate that this task is the final task
    for the TransferFuture request. By setting this value to True, it
    will set the result of the entire TransferFuture to the result
    returned by this task's main() method.
N)_transfer_coordinator_main_kwargs_pending_main_kwargs_done_callbacks	_is_final)selftransfer_coordinatormain_kwargspending_main_kwargsdone_callbacksis_finals         P/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/s3transfer/tasks.py__init__Task.__init__   sX    P &:"'$ "D$7!&(*D%-'#%D !    c                     / SQnU R                  U R                  U5      nU R                  R                   SU R                  R
                   SU S3$ )N)bucketkeypart_numberfinal_filenametransfer_futureoffset
extra_argsz(transfer_id=z, ))"_get_kwargs_with_params_to_includer	   	__class____name__r   transfer_id)r   params_to_displaymain_kwargs_to_displays      r   __repr__Task.__repr__T   s`    
 "&!H!H0"
 ..))*-8R8R8^8^7__abxayyz{{r   c                 .    U R                   R                  $ )z8The id for the transfer request that the task belongs to)r   r#   )r   s    r   r#   Task.transfer_ide   s     ))555r   c                 6    0 nU H  nXA;   d  M
  X   X4'   M     U$ N )r   kwargsincludefiltered_kwargsparams        r   r    'Task._get_kwargs_with_params_to_includej   s(    E)/&  r   c                 R    0 nUR                  5        H  u  pEXB;   a  M  XSU'   M     U$ r+   )items)r   r-   excluder/   r0   values         r   "_get_kwargs_with_params_to_exclude'Task._get_kwargs_with_params_to_excludeq   s2    "LLNLE%*E" + r   c                     U R                  5         U R                  5       nU R                  R                  5       (       dW  U R	                  U5      U R
                   H
  nU" 5         M     U R                  (       a  U R                  R                  5         $ $  U R
                   H
  nU" 5         M     U R                  (       a  U R                  R                  5         gg! [         a  nU R                  U5         SnANgSnAff = f! U R
                   H
  nU" 5         M     U R                  (       a  U R                  R                  5         f f = f)z9The callable to use when submitting a Task to an executorN)
_wait_on_dependent_futures_get_all_main_kwargsr   done_execute_mainr   r   announce_done	Exception_log_and_set_exception)r   r-   done_callbackes       r   __call__Task.__call__y   s   	;++-
 ..0F --2244))&1
 "&!5!5 "6 ~~ **88:  5 "&!5!5 "6 ~~ **88:   	+''**	+ "&!5!5 "6 ~~ **88: s1   AC  D  
D*D ;D  DD AEc                     S/nU R                  X5      n[        R                  SU  SU 35        U R                  " S0 UD6nU R                  (       a  U R
                  R                  U5        U$ )NdatazExecuting task z with kwargs r,   )r6   loggerdebug_mainr   r   
set_result)r   r-   params_to_excludekwargs_to_displayreturn_values        r   r<   Task._execute_main   sq     $H CC
 	tfM:K9LMNzz+F+ >>&&11,?r   c                 b    [         R                  SSS9  U R                  R                  U5        g )NzException raised.T)exc_info)rF   rG   r   set_exception)r   	exceptions     r   r?   Task._log_and_set_exception   s)     	(48""00;r   c                     [        S5      e)zThe method that will be ran in the executor

This method must be implemented by subclasses from Task. main() can
be implemented with any arguments decided upon by the subclass.
z_main() must be implementedNotImplementedError)r   r-   s     r   rH   
Task._main   s     ""?@@r   c                     / nU R                   R                  5        H>  u  p#[        U[        5      (       a  UR	                  U5        M-  UR                  U5        M@     U R                  U5        g r+   )r
   r3   
isinstancelistextendappend_wait_until_all_complete)r   futures_to_wait_on_futures       r   r9   Task._wait_on_dependent_futures   s_    2288:IA&$''"))&1 #))&1 ; 	%%&89r   c                     [         R                  SX5        U H*  n [         R                  SX5        UR                  5         M,     [         R                  SU 5        g ! [         a     MR  f = f)Nz-%s about to wait for the following futures %sz%s about to wait for %sz%%s done waiting for dependent futures)rF   rG   resultr>   )r   futuresr_   s      r   r\   Task._wait_until_all_complete   se     	;T	
 F6E  	<dC	   s   &A
A,+A,c                 4   [         R                   " U R                  5      nU R                  R                  5        HY  u  p#[	        U[
        5      (       a+  / nU H"  nUR                  UR                  5       5        M$     OUR                  5       nXAU'   M[     U$ r+   )copyr	   r
   r3   rX   rY   r[   rb   )r   r-   r   pending_valuerb   r_   s         r   r:   Task._get_all_main_kwargs   s    4,,- #'";";"A"A"CC -..+FMM&--/2 , '--/ !3K #D r   )r   r   r	   r
   r   )NNNF)r"   
__module____qualname____firstlineno____doc__r   r&   propertyr#   r    r6   rB   r<   r?   rH   r9   r\   r:   __static_attributes__r,   r   r   r   r      sd      6"p|" 6 6;6"<A:D,r   r   c                   *    \ rS rSrSrS rS rS rSrg)SubmissionTask   zA base class for any submission task

Submission tasks are the top-level task used to submit a series of tasks
to execute a particular transfer.
c                 r    U R                   R                  5         [        US5      nU H
  nU" 5         M     U R                   R                  5         U R                  " SSU0UD6  g! [
         aE  nU R                  U5        U R                  5         U R                   R                  5          SnAgSnAff = f)a  
:type transfer_future: s3transfer.futures.TransferFuture
:param transfer_future: The transfer future associated with the
    transfer request that tasks are being submitted for

:param kwargs: Any additional kwargs that you may want to pass
    to the _submit() method
queuedr   Nr,   )	r   set_status_to_queuedr   set_status_to_running_submitBaseExceptionr?   +_wait_for_all_submitted_futures_to_completer=   )r   r   r-   on_queued_callbackson_queued_callbackrA   s         r   rH   SubmissionTask._main   s    $	7&&;;= #0"J&9""$ ': &&<<> LLCCFC 	7 ''*
 <<> &&4466-	7s   A$A' '
B61;B11B6c                     [        S5      e)a(  The submission method to be implemented

:type transfer_future: s3transfer.futures.TransferFuture
:param transfer_future: The transfer future associated with the
    transfer request that tasks are being submitted for

:param kwargs: Any additional keyword arguments you want to be passed
    in
z_submit() must be implementedrT   )r   r   r-   s      r   rv   SubmissionTask._submit"  s     ""ABBr   c                     U R                   R                  nU(       a9  U R                  U5        U R                   R                  nX:X  a  g UnU(       a  M8  g g r+   )r   associated_futuresr\   )r   submitted_futurespossibly_more_submitted_futuress      r   rx   :SubmissionTask._wait_for_all_submitted_futures_to_complete.  sW     !66II))*;< **== , !C ?!  r   r,   N)	r"   ri   rj   rk   rl   rH   rv   rx   rn   r,   r   r   rp   rp      s    -7^
C@r   rp   c                       \ rS rSrSrS rSrg)CreateMultipartUploadTaskiJ  z#Task to initiate a multipart uploadc                     UR                   " SX#S.UD6nUS   nU R                  R                  UR                  UUUS9  U$ )a9  
:param client: The client to use when calling CreateMultipartUpload
:param bucket: The name of the bucket to upload to
:param key: The name of the key to upload to
:param extra_args: A dictionary of any extra arguments that may be
    used in the initialization.

:returns: The upload id of the multipart upload
)BucketKeyUploadId)r   r   r   r,   )create_multipart_uploadr   add_failure_cleanupabort_multipart_upload)r   clientr   r   r   response	upload_ids          r   rH   CreateMultipartUploadTask._mainM  se     11 

&0
 Z(	 	""66))	 	7 	
 r   r,   Nr"   ri   rj   rk   rl   rH   rn   r,   r   r   r   r   J  s
    -r   r   c                       \ rS rSrSrS rSrg)CompleteMultipartUploadTaskig  z#Task to complete a multipart uploadc                 6    UR                   " SUUUSU0S.UD6  g)a"  
:param client: The client to use when calling CompleteMultipartUpload
:param bucket: The name of the bucket to upload to
:param key: The name of the key to upload to
:param upload_id: The id of the upload
:param parts: A list of parts to use to complete the multipart upload::

    [{'Etag': etag_value, 'PartNumber': part_number}, ...]

    Each element in the list consists of a return value from
    ``UploadPartTask.main()``.
:param extra_args:  A dictionary of any extra arguments that may be
    used in completing the multipart transfer.
Parts)r   r   r   MultipartUploadNr,   )complete_multipart_upload)r   r   r   r   r   partsr   s          r   rH   !CompleteMultipartUploadTask._mainj  s2     	(( 	
$e,		

 	
r   r,   Nr   r,   r   r   r   r   g  s
    -
r   r   )rf   loggings3transfer.utilsr   	getLoggerr"   rF   r   rp   r   r   r,   r   r   <module>r      sV      *			8	$T Tn[@T [@| :
$ 
r   