Current File : //proc/353637/cwd/usr/lib/python3/dist-packages/s3transfer/__pycache__/tasks.cpython-312.pyc
�

�<�e??���ddlZddlZddlmZeje�ZGd�d�ZGd�de�ZGd�de�Z	Gd	�d
e�Z
y)�N)�
get_callbacksc�l�eZdZdZ				dd�Zd�Zed��Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zy)�Taskz�A 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��||_||_|j�i|_||_|�i|_||_|j�g|_||_y)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      �2/usr/lib/python3/dist-packages/s3transfer/tasks.py�__init__z
Task.__init__sb��P&:��"�'������$� "�D��$7��!��&�(*�D�%�-������'�#%�D� �!���c��gd�}|j|j|�}dj|jj|j
j|�S)N)�bucket�key�part_number�final_filename�transfer_future�offset�
extra_argsz{}(transfer_id={}, {}))�"_get_kwargs_with_params_to_includer�format�	__class__�__name__r�transfer_id)r�params_to_display�main_kwargs_to_displays   r�__repr__z
Task.__repr__Ts]��
��"&�!H�!H����0�"
��(�.�.��N�N�#�#��&�&�2�2�"�
�	
rc�.�|jjS)z8The id for the transfer request that the task belongs to)rr!)rs rr!zTask.transfer_idis���)�)�5�5�5rc�2�i}|D]}||vs�||||<�|S�N�)r�kwargs�include�filtered_kwargs�params     rrz'Task._get_kwargs_with_params_to_includens3�����	7�E����)/�����&�	7��rc�N�i}|j�D]\}}||vr�|||<�|Sr')�items)rr)�excluder+r,�values      r�"_get_kwargs_with_params_to_excludez'Task._get_kwargs_with_params_to_excludeus=����"�L�L�N�	+�L�E�5�����%*�O�E�"�	+��rc�p�	|j�|j�}|jj�sP|j	|�|j
D]	}|��|jr|jj�SS	|j
D]	}|��|jr|jj�yy#t$r}|j|�Yd}~�_d}~wwxYw#|j
D]	}|��|jr|jj�wwxYw)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__z
Task.__call__}s(��	;��+�+�-�
�.�.�0�F��-�-�2�2�4��)�)�&�1�
"&�!5�!5�
 �
���
 ��~�~��*�*�8�8�:��5�"&�!5�!5�
 �
���
 ��~�~��*�*�8�8�:����	+��'�'��*�*��	+��"&�!5�!5�
 �
���
 ��~�~��*�*�8�8�:��s1�A
C
�C4�
	C1�C,�'C4�,C1�1C4�4AD5c���dg}|j||�}tjd|�d|���|jdi|��}|jr|j
j
|�|S)N�datazExecuting task z
 with kwargs r()r1�logger�debug�_mainrr�
set_result)rr)�params_to_exclude�kwargs_to_display�return_values     rr6zTask._execute_main�sv��$�H�� �C�C��%�
��	����t�f�M�:K�9L�M�N�!�t�z�z�+�F�+���>�>��&�&�1�1�,�?��rc�h�tjdd��|jj|�y)NzException raised.T)�exc_info)r?r@r�
set_exception)r�	exceptions  rr9zTask._log_and_set_exception�s)��	���(�4��8��"�"�0�0��;rc��td��)z�The 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  rrAz
Task._main�s��"�"?�@�@rc���g}|jj�D]8\}}t|t�r|j	|��(|j|��:|j
|�yr')r	r.�
isinstance�list�extend�append�_wait_until_all_complete)r�futures_to_wait_on�_�futures    rr3zTask._wait_on_dependent_futures�sc�����2�2�8�8�:�	2�I�A�v��&�$�'�"�)�)�&�1�#�)�)�&�1�
	2�	
�%�%�&8�9rc���tjd||�|D]*}	tjd||�|j��,tjd|�y#t$rY�OwxYw)Nz-%s about to wait for the following futures %sz%s about to wait for %sz%%s done waiting for dependent futures)r?r@�resultr8)r�futuresrUs   rrRzTask._wait_until_all_complete�sn��	���;�T�7�	
��	�F�
����6��f�E��
�
��	�	���<�d�C��	�
��
�s�'A�	A*�)A*c�$�tj|j�}|jj�D]S\}}t	|t
�r)g}|D]!}|j
|j���#n|j�}|||<�U|Sr')�copyrr	r.rNrOrQrW)rr)r�
pending_valuerWrUs      rr4zTask._get_all_main_kwargs�s������4�,�,�-��#'�";�";�"A�"A�"C�	!��C���-��.���+�3�F��M�M�&�-�-�/�2�3�'�-�-�/��!�F�3�K�	!��
r)NNNF)r �
__module__�__qualname__�__doc__rr$�propertyr!rr1r<r6r9rAr3rRr4r(rrrrsc���� ���
6"�p
�*�6��6���;�6�"<�A�:�D�,rrc�"�eZdZdZd�Zd�Zd�Zy)�SubmissionTaskz�A 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�l�	|jj�t|d�}|D]	}|��|jj�|jdd|i|��y#t
$rE}|j
|�|j�|jj�Yd}~yd}~wwxYw)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
        �queuedrNr()	r�set_status_to_queuedr�set_status_to_running�_submit�
BaseExceptionr9�+_wait_for_all_submitted_futures_to_completer7)rrr)�on_queued_callbacks�on_queued_callbackr;s      rrAzSubmissionTask._main�s���$	7��&�&�;�;�=�#0���"J��&9�
%�"�"�$�
%�
�&�&�<�<�>�
�D�L�L�C��C�F�C���	7�
�'�'��*�

�<�<�>�
�&�&�4�4�6�6��-	7�s�A"A%�%	B3�.;B.�.B3c��td��)aXThe 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 implementedrK)rrr)s   rrfzSubmissionTask._submit&s��"�"A�B�Brc��|jj}|r3|j|�|jj}||k(ry|}|r�2yyr')r�associated_futuresrR)r�submitted_futures�possibly_more_submitted_futuress   rrhz:SubmissionTask._wait_for_all_submitted_futures_to_complete2sW��!�6�6�I�I����)�)�*;�<��*�*�=�=�
,�!�$C�C�� ?��! rN)r r\r]r^rArfrhr(rrrara�s���-7�^
C�@rrac��eZdZdZd�Zy)�CreateMultipartUploadTaskz#Task to initiate a multipart uploadc��|jd||d�|��}|d}|jj|j|||��|S)aq
        :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)rsrtrur()�create_multipart_uploadr�add_failure_cleanup�abort_multipart_upload)r�clientrrr�response�	upload_ids       rrAzCreateMultipartUploadTask._mainQsi��2�6�1�1�
��s�
�&0�
���Z�(�	�	
�"�"�6�6��)�)����		7�	
��rN�r r\r]r^rAr(rrrqrqNs
��-�rrqc��eZdZdZd�Zy)�CompleteMultipartUploadTaskz#Task to complete a multipart uploadc�6�|jd|||d|id�|��y)az
        :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)rsrtru�MultipartUploadNr()�complete_multipart_upload)rryrrr{�partsrs       rrAz!CompleteMultipartUploadTask._mainns4��	)��(�(�	
����$�e�,�		
�
�	
rNr|r(rrr~r~ks
��-�
rr~)rZ�logging�s3transfer.utilsr�	getLoggerr r?rrarqr~r(rr�<module>r�sX����*�	��	�	�8�	$��X�X�v[@�T�[@�|���:
�$�
r