403Webshell
Server IP : 178.105.222.151  /  Your IP : 216.73.216.38
Web Server : nginx/1.28.3
System : Linux MNK 7.0.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Wed Apr 22 16:06:43 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.5.4
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/s3transfer/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/s3transfer/__pycache__/processpool.cpython-314.pyc
+
[m�hҍ���Rt^RIt^RIt^RIt^RIt^RIt^RIt^RIHt^RI	t
^RIHt^RI
HtHt^RIHtHtHt^RIHtHt^RIHtHt^RIHtHtHtHtHtH t ]PB!]"4t#R	t$]PJ!R
.R$O4t&]PJ!R.R%O4t']PPR4t)R
t*!RR4t+!RR4t,!RR]4t-!RR]4t.!RR4t/!RR4t0!RR4t1!RR]4t2]2PgR]04!RR]Ph4t5!R R!]54t6!R"R#]54t7R#)&aCSpeeds up S3 throughput by using processes

Getting Started
===============

The :class:`ProcessPoolDownloader` can be used to download a single file by
calling :meth:`ProcessPoolDownloader.download_file`:

.. code:: python

     from s3transfer.processpool import ProcessPoolDownloader

     with ProcessPoolDownloader() as downloader:
          downloader.download_file('mybucket', 'mykey', 'myfile')


This snippet downloads the S3 object located in the bucket ``mybucket`` at the
key ``mykey`` to the local file ``myfile``. Any errors encountered during the
transfer are not propagated. To determine if a transfer succeeded or
failed, use the `Futures`_ interface.


The :class:`ProcessPoolDownloader` can be used to download multiple files as
well:

.. code:: python

     from s3transfer.processpool import ProcessPoolDownloader

     with ProcessPoolDownloader() as downloader:
          downloader.download_file('mybucket', 'mykey', 'myfile')
          downloader.download_file('mybucket', 'myotherkey', 'myotherfile')


When running this snippet, the downloading of ``mykey`` and ``myotherkey``
happen in parallel. The first ``download_file`` call does not block the
second ``download_file`` call. The snippet blocks when exiting
the context manager and blocks until both downloads are complete.

Alternatively, the ``ProcessPoolDownloader`` can be instantiated
and explicitly be shutdown using :meth:`ProcessPoolDownloader.shutdown`:

.. code:: python

     from s3transfer.processpool import ProcessPoolDownloader

     downloader = ProcessPoolDownloader()
     downloader.download_file('mybucket', 'mykey', 'myfile')
     downloader.download_file('mybucket', 'myotherkey', 'myotherfile')
     downloader.shutdown()


For this code snippet, the call to ``shutdown`` blocks until both
downloads are complete.


Additional Parameters
=====================

Additional parameters can be provided to the ``download_file`` method:

* ``extra_args``: A dictionary containing any additional client arguments
  to include in the
  `GetObject <https://botocore.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.get_object>`_
  API request. For example:

  .. code:: python

     from s3transfer.processpool import ProcessPoolDownloader

     with ProcessPoolDownloader() as downloader:
          downloader.download_file(
               'mybucket', 'mykey', 'myfile',
               extra_args={'VersionId': 'myversion'})


* ``expected_size``: By default, the downloader will make a HeadObject
  call to determine the size of the object. To opt-out of this additional
  API call, you can provide the size of the object in bytes:

  .. code:: python

     from s3transfer.processpool import ProcessPoolDownloader

     MB = 1024 * 1024
     with ProcessPoolDownloader() as downloader:
          downloader.download_file(
               'mybucket', 'mykey', 'myfile', expected_size=2 * MB)


Futures
=======

When ``download_file`` is called, it immediately returns a
:class:`ProcessPoolTransferFuture`. The future can be used to poll the state
of a particular transfer. To get the result of the download,
call :meth:`ProcessPoolTransferFuture.result`. The method blocks
until the transfer completes, whether it succeeds or fails. For example:

.. code:: python

     from s3transfer.processpool import ProcessPoolDownloader

     with ProcessPoolDownloader() as downloader:
          future = downloader.download_file('mybucket', 'mykey', 'myfile')
          print(future.result())


If the download succeeds, the future returns ``None``:

.. code:: python

     None


If the download fails, the exception causing the failure is raised. For
example, if ``mykey`` did not exist, the following error would be raised


.. code:: python

     botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found


.. note::

    :meth:`ProcessPoolTransferFuture.result` can only be called while the
    ``ProcessPoolDownloader`` is running (e.g. before calling ``shutdown`` or
    inside the context manager).


Process Pool Configuration
==========================

By default, the downloader has the following configuration options:

* ``multipart_threshold``: The threshold size for performing ranged downloads
  in bytes. By default, ranged downloads happen for S3 objects that are
  greater than or equal to 8 MB in size.

* ``multipart_chunksize``: The size of each ranged download in bytes. By
  default, the size of each ranged download is 8 MB.

* ``max_request_processes``: The maximum number of processes used to download
  S3 objects. By default, the maximum is 10 processes.


To change the default configuration, use the :class:`ProcessTransferConfig`:

.. code:: python

     from s3transfer.processpool import ProcessPoolDownloader
     from s3transfer.processpool import ProcessTransferConfig

     config = ProcessTransferConfig(
          multipart_threshold=64 * 1024 * 1024,  # 64 MB
          max_request_processes=50
     )
     downloader = ProcessPoolDownloader(config=config)


Client Configuration
====================

The process pool downloader creates ``botocore`` clients on your behalf. In
order to affect how the client is created, pass the keyword arguments
that would have been used in the :meth:`botocore.Session.create_client` call:

.. code:: python


     from s3transfer.processpool import ProcessPoolDownloader
     from s3transfer.processpool import ProcessTransferConfig

     downloader = ProcessPoolDownloader(
          client_kwargs={'region_name': 'us-west-2'})


This snippet ensures that all clients created by the ``ProcessPoolDownloader``
are using ``us-west-2`` as their region.

N)�deepcopy)�Config)�MAXINT�BaseManager)�ALLOWED_DOWNLOAD_ARGS�MB�PROCESS_USER_AGENT)�CancelledError�RetriesExceededError)�BaseTransferFuture�BaseTransferMeta)�S3_RETRYABLE_DOWNLOAD_ERRORS�CallArgs�OSUtils�calculate_num_parts�calculate_range_parameter�create_nested_client�SHUTDOWN�DownloadFileRequest�GetObjectJobc#�t"�\4pRx�\P!\PV4R#5i�N)�"_add_ignore_handler_for_interrupts�signal�SIGINT)�original_handlers �8/usr/lib/python3/dist-packages/s3transfer/processpool.py�
ignore_ctrl_crs$���9�;��	�
�M�M�&�-�-�!1�2�s�68c�h�\P!\P\P4#r)rr�SIG_IGN��rrr	s���=�=�������7�7r!c�La�]tRtRto^],^],^
3RltRtVtR#)�ProcessTransferConfigic�*�WnW nW0nR#)aEConfiguration for the ProcessPoolDownloader

:param multipart_threshold: The threshold for which ranged downloads
    occur.

:param multipart_chunksize: The chunk size of each ranged download.

:param max_request_processes: The maximum number of processes that
    will be making S3 API transfer-related requests at a time.
N)�multipart_threshold�multipart_chunksize�max_request_processes)�selfr%r&r's&&&&r�__init__�ProcessTransferConfig.__init__s�� $7� �#6� �%:�"r!)r'r&r%N)�__name__�
__module__�__qualname__�__firstlineno__rr)�__static_attributes__�__classdictcell__��
__classdict__s@rr#r#s"������F���F� �	;�;r!r#c�a�]tRtRtoRRltRRltRtRtRtRt	R	t
R
tRtRt
R
tRtRtRtRtRtRtRtVtR#)�ProcessPoolDownloaderi%Nc�h�Vf/p\V4VnW nVf\4Vn\P
!R4Vn\P
!R4Vn\4Vn	RVn
\P!4Vn
RVnRVnRVn.VnR#)amDownloads S3 objects using process pools

:type client_kwargs: dict
:param client_kwargs: The keyword arguments to provide when
    instantiating S3 clients. The arguments must match the keyword
    arguments provided to the
    `botocore.session.Session.create_client()` method.

:type config: ProcessTransferConfig
:param config: Configuration for the downloader
Ni�F)�
ClientFactory�_client_factory�_transfer_configr#�multiprocessing�Queue�_download_request_queue�
_worker_queuer�_osutil�_started�	threading�Lock�_start_lock�_manager�_transfer_monitor�
_submitter�_workers)r(�
client_kwargs�configs&&&rr)�ProcessPoolDownloader.__init__&s���� ��M�,�]�;��� &���>�$9�$;�D�!�'6�'<�'<�T�'B��$�,�2�2�4�8����y�����
�$�>�>�+�����
�!%��������
r!c	�N�VP4Vf/pVPV4VPP4p\	VVVVVVR7p\
P
RV4VPPV4\VVVVVR7pVPWh4p	V	#)a�Downloads the object's contents to a file

: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 filename: str
:param filename: The name of a file to download to.

:type extra_args: dict
:param extra_args: Extra arguments that may be passed to the
    client operation

:type expected_size: int
:param expected_size: The expected size in bytes of the download. If
    provided, the downloader will not call HeadObject to determine the
    object's size and use the provided value instead. The size is
    needed to determine whether to do a multipart download.

:rtype: s3transfer.futures.TransferFuture
:returns: Transfer future representing the download
��transfer_id�bucket�key�filename�
extra_args�
expected_sizez%Submitting download file request: %s.)rLrMrNrOrP)�_start_if_needed�_validate_all_known_argsrC�notify_new_transferr�logger�debugr;�putr�_get_transfer_future)
r(rLrMrNrOrPrK�download_file_request�	call_args�futures
&&&&&&    r�
download_file�#ProcessPoolDownloader.download_fileGs���6	
�������J��%�%�j�1��,�,�@�@�B�� 3�#����!�'�
!
��	���3�5J�	
�	
�$�$�(�(�)>�?�����!�'�
�	��*�*�;�B���
r!c�&�VP4R#)zXShutdown the downloader

It will wait till all downloads are complete before returning.
N)�_shutdown_if_needed�r(s&r�shutdown�ProcessPoolDownloader.shutdown}s��
	
� � �"r!c��V#rr r_s&r�	__enter__�ProcessPoolDownloader.__enter__�s���r!c��\V\4'd)VPeVPP4VP	4R#r)�
isinstance�KeyboardInterruptrC�notify_cancel_all_in_progressr`)r(�exc_type�	exc_value�argss&&&*r�__exit__�ProcessPoolDownloader.__exit__�s7���i�!2�3�3��%�%�1��&�&�D�D�F��
�
�r!c��VP;_uu_4VP'gVP4RRR4R# +'giR#;ir)rAr>�_startr_s&rrQ�&ProcessPoolDownloader._start_if_needed�s/��
�
�
�
��=�=�=����
��
�
�
���#A�A	c�t�VP4VP4VP4RVnR#)TN)�_start_transfer_monitor_manager�_start_submitter�_start_get_object_workersr>r_s&rro�ProcessPoolDownloader._start�s-���,�,�.������&�&�(���
r!c�z�VF4pV\9gKRP\4p\RVRV24h	R#)z, zInvalid extra_args key 'z', must be one of: N)r�join�
ValueError)r(�provided�kwarg�
download_argss&&  rrR�.ProcessPoolDownloader._validate_all_known_args�sG���E��1�1� $�	�	�*?� @�
� �.�u�g�6'�'4�o�7���r!c�L�\W!R7p\VPVR7pV#))rYrK)�monitor�meta)�ProcessPoolTransferMeta�ProcessPoolTransferFuturerC)r(rKrYr�rZs&&&  rrW�*ProcessPoolDownloader._get_transfer_future�s-��&��
��+��*�*��
���
r!c���\PR4\4VnVPP	\
4VPP
4VnR#)z$Starting the TransferMonitorManager.N)rTrU�TransferMonitorManagerrB�startr�TransferMonitorrCr_s&rrs�5ProcessPoolDownloader._start_transfer_monitor_manager�sC�����;�<�.�0��
�
	
�
�
���>�?�!%���!>�!>�!@��r!c	��\PR4\VPVPVP
VPVPVPR7Vn	VPP4R#)z Starting the GetObjectSubmitter.)�transfer_config�client_factory�transfer_monitor�osutil�download_request_queue�worker_queueN)rTrU�GetObjectSubmitterr8r7rCr=r;r<rDr�r_s&rrt�&ProcessPoolDownloader._start_submitter�sa�����7�8�,� �1�1��/�/�!�3�3��<�<�#'�#?�#?��+�+�

���	
�����r!c�j�\PRVPP4\	VPP4Fep\VPVPVPVPR7pVP4VPPV4Kg	R#)zStarting %s GetObjectWorkers.)�queuer�r�r�N)
rTrUr8r'�range�GetObjectWorkerr<r7rCr=r�rE�append�r(�_�workers&  rru�/ProcessPoolDownloader._start_get_object_workers�s������+��!�!�7�7�	
��t�,�,�B�B�C�A�$��(�(�#�3�3�!%�!7�!7��|�|�	�F�
�L�L�N��M�M� � ��(�Dr!c��VP;_uu_4VP'dVP4RRR4R# +'giR#;ir)rAr>�	_shutdownr_s&rr^�)ProcessPoolDownloader._shutdown_if_needed�s0��
�
�
�
��}�}�}���� ��
�
�
�rqc�t�VP4VP4VP4RVnR#)FN)�_shutdown_submitter�_shutdown_get_object_workers�"_shutdown_transfer_monitor_managerr>r_s&rr��ProcessPoolDownloader._shutdown�s-��� � �"��)�)�+��/�/�1���
r!c�d�\PR4VPP4R#)z)Shutting down the TransferMonitorManager.N)rTrUrBr`r_s&rr��8ProcessPoolDownloader._shutdown_transfer_monitor_manager�s�����@�A��
�
��� r!c��\PR4VPP\4VP
P
4R#)z%Shutting down the GetObjectSubmitter.N)rTrUr;rV�SHUTDOWN_SIGNALrDrxr_s&rr��)ProcessPoolDownloader._shutdown_submitter�s3�����<�=��$�$�(�(��9������r!c���\PR4VPF"pVPP	\
4K$	VPFpVP
4K	R#)z#Shutting down the GetObjectWorkers.N)rTrUrEr<rVr�rxr�s&  rr��2ProcessPoolDownloader._shutdown_get_object_workers�sH�����:�;����A����"�"�?�3���m�m�F��K�K�M�$r!)r7r;rBr=rAr>rDr8rCr<rE)NN)r+r,r-r.r)r[r`rcrlrQrorRrWrsrtrur^r�r�r�r�r/r0r1s@rr4r4%sb�����B4�l#����
���A�
 �
)�!�
�!��
�r!r4c�Ha�]tRtRtoRt]R4tRtRtRt	Rt
VtR#)	r�i�c��WnW nR#)a0The future associated to a submitted process pool transfer request

:type monitor: TransferMonitor
:param monitor: The monitor associated to the process pool downloader

:type meta: ProcessPoolTransferMeta
:param meta: The metadata associated to the request. This object
    is visible to the requester.
N)�_monitor�_meta)r(rr�s&&&rr)�"ProcessPoolTransferFuture.__init__�s�� �
��
r!c��VP#r)r�r_s&rr��ProcessPoolTransferFuture.meta�s���z�z�r!c�`�VPPVPP4#r)r��is_doner�rKr_s&r�done�ProcessPoolTransferFuture.done�s!���}�}�$�$�T�Z�Z�%;�%;�<�<r!c���VPPVPP4# \d-TPP4TP
4hi;ir)r��poll_for_resultr�rKrg�_connect�cancelr_s&r�result� ProcessPoolTransferFuture.resultsS��	��=�=�0�0����1G�1G�H�H�� �	�
�M�M�"�"�$��K�K�M��!	�s	�.1�7A(c�v�VPPVPP\	44R#r)r��notify_exceptionr�rKr	r_s&rr�� ProcessPoolTransferFuture.cancels&���
�
�&�&��J�J�"�"�N�$4�	
r!)r�r�N)r+r,r-r.r)�propertyr�r�r�r�r/r0r1s@rr�r��s2���������=��*
�
r!r�c�Za�]tRtRtoRtRt]R4t]R4t]R4t	Rt
VtR#)	r�iz2Holds metadata about the ProcessPoolTransferFuturec�,�WnW n/VnR#r)�_transfer_id�
_call_args�
_user_context)r(rKrYs&&&rr)� ProcessPoolTransferMeta.__init__s��'��#����r!c��VP#r)r�r_s&rrY�!ProcessPoolTransferMeta.call_args#������r!c��VP#r)r�r_s&rrK�#ProcessPoolTransferMeta.transfer_id's��� � � r!c��VP#r)r�r_s&r�user_context�$ProcessPoolTransferMeta.user_context+s���!�!�!r!)r�r�r�N)r+r,r-r.�__doc__r)r�rYrKr�r/r0r1s@rr�r�sI����<� �
�����!��!��"��"r!r�c�0a�]tRtRtoRRltRtRtVtR#)r6i0Nc�6�WnVPf/Vn\VPPR\444pVP'g
\
VnM$V;PR\
,,
unW PR&R#)z�Creates S3 clients for processes

Botocore sessions and clients are not pickleable so they cannot be
inherited across Process boundaries. Instead, they must be instantiated
once a process is running.
NrG� )�_client_kwargsr�getr�user_agent_extrar)r(rF�
client_configs&& rr)�ClientFactory.__init__1sv��,�����&�"$�D�� ��!4�!4�!8�!8��6�8�!L�M�
��-�-�-�-?�M�*��*�*�c�4F�.F�F�*�(5���H�%r!c�l�\PP4p\VR3/VPB#)zCreate a botocore S3 client�s3)�botocore�session�Sessionrr�)r(r�s& r�
create_client�ClientFactory.create_clientCs.���"�"�*�*�,��#�G�T�I�T�5H�5H�I�Ir!)r�r)r+r,r-r.r)r�r/r0r1s@rr6r60s����6�$J�Jr!r6c�\a�]tRtRtoRtRtRtRtRtRt	Rt
R	tR
tRt
RtVtR
#)r�iIc�V�/Vn^Vn\P!4VnR#)aMonitors transfers for cross-process communication

Notifications can be sent to the monitor and information can be
retrieved from the monitor for a particular transfer. This abstraction
is ran in a ``multiprocessing.managers.BaseManager`` in order to be
shared across processes.
N)�_transfer_states�	_id_countr?r@�
_init_lockr_s&rr)�TransferMonitor.__init__Js!��!#������#�.�.�*��r!c���VP;_uu_4VPp\4VPV&V;P^,
unVuuRRR4# +'giR#;i��N)r�r��
TransferStater��r(rKs& rrS�#TransferMonitor.notify_new_transferZsC��
�_�_�_��.�.�K�1>��D�!�!�+�.��N�N�a��N��	�_�_�_�s�>A�A/	c�<�VPV,P#)z�Determine a particular transfer is complete

:param transfer_id: Unique identifier for the transfer
:return: True, if done. False, otherwise.
)r�r�r�s&&rr��TransferMonitor.is_doneas���$�$�[�1�6�6�6r!c�H�VPV,P4R#)zaNotify a particular transfer is complete

:param transfer_id: Unique identifier for the transfer
N)r��set_doner�s&&r�notify_done�TransferMonitor.notify_doneis��
	
���k�*�3�3�5r!c��VPV,P4VPV,PpV'dVhR#)z�Poll for the result of a transfer

:param transfer_id: Unique identifier for the transfer
:return: If the transfer succeeded, it will return the result. If the
    transfer failed, it will raise the exception associated to the
    failure.
N)r��wait_till_done�	exception�r(rKr�s&& rr��TransferMonitor.poll_for_resultps<��	
���k�*�9�9�;��)�)�+�6�@�@�	���O�r!c�4�W PV,nR#)z�Notify an exception was encountered for a transfer

:param transfer_id: Unique identifier for the transfer
:param exception: The exception encountered for that transfer
N�r�r�r�s&&&rr�� TransferMonitor.notify_exception~s��8A���k�*�4r!c��VPP4F&pVP'dK\4VnK(	R#r)r��valuesr�r	r�)r(�transfer_states& rrh�-TransferMonitor.notify_cancel_all_in_progress�s2��"�3�3�:�:�<�N�!�&�&�&�+9�+;��(�=r!c�<�VPV,P#)z�Retrieve the exception encountered for the transfer

:param transfer_id: Unique identifier for the transfer
:return: The exception encountered for that transfer. Otherwise
    if there were no exceptions, returns None.
r�r�s&&r�
get_exception�TransferMonitor.get_exception�s���$�$�[�1�;�;�;r!c�4�W PV,nR#)z�Notify the amount of jobs expected for a transfer

:param transfer_id: Unique identifier for the transfer
:param num_jobs: The number of jobs to complete the transfer
N)r��jobs_to_complete)r(rK�num_jobss&&&r� notify_expected_jobs_to_complete�0TransferMonitor.notify_expected_jobs_to_complete�s��?G���k�*�;r!c�D�VPV,P4#)z�Notify that a single job is completed for a transfer

:param transfer_id: Unique identifier for the transfer
:return: The number of jobs remaining to complete the transfer
)r��decrement_jobs_to_completer�s&&r�notify_job_complete�#TransferMonitor.notify_job_complete�s���$�$�[�1�L�L�N�Nr!)r�r�r�N)r+r,r-r.r)rSr�r�r�r�rhr�rrr/r0r1s@rr�r�Is@����+� �7�6��
A�<�
<�G�O�Or!r�c�a�]tRtRtoRtRt]R4tRtRt	]R4t
]
PR4t
]R	4t]PR
4tRt
RtVtR
#)r�i�z6Represents the current state of an individual transferc��RVn\P!4Vn\P!4Vn^VnR#r)�
_exceptionr?�Event�_done_eventr@�	_job_lock�_jobs_to_completer_s&rr)�TransferState.__init__�s.�����$�?�?�,���"���)���!"��r!c�6�VPP4#r)r�is_setr_s&rr��TransferState.done�s�����&�&�(�(r!c�:�VPP4R#r)r�setr_s&rr��TransferState.set_done�s�������r!c�D�VPP\4R#r)r�waitrr_s&rr��TransferState.wait_till_done�s�������f�%r!c��VP#r�r	r_s&rr��TransferState.exception�r�r!c��WnR#rr�r(�vals&&rr�r�s���r!c��VP#r�r
r_s&rr��TransferState.jobs_to_complete�s���%�%�%r!c��WnR#rrrs&&rr�r �s��!$�r!c��VP;_uu_4V;P^,unVPuuRRR4# +'giR#;ir�)rr
r_s&rr�(TransferState.decrement_jobs_to_complete�s1��
�^�^�^��"�"�a�'�"��)�)��^�^�^�s�%A�A	)rr	rr
N)r+r,r-r.r�r)r�r�r�r�r��setterr�rr/r0r1s@rr�r��s�����@�#��)��)��&������������&��&����%��%�*�*r!r�c��]tRtRtRtR#)r�i�r N)r+r,r-r.r/r r!rr�r��s��r!r�c�>aa�]tRtRtoV3RltRtRtRtVtV;t	#)�BaseS3TransferProcessi�c�><�\SV`4WnRVnR#r)�superr)r7�_client)r(r��	__class__s&&�rr)�BaseS3TransferProcess.__init__�s���
����-����r!c���VPP4Vn\4;_uu_4VP	4RRR4R# +'giR#;ir)r7r�r*r�_do_runr_s&r�run�BaseS3TransferProcess.run�s8���+�+�9�9�;���
�_�_�
�L�L�N��_�_�_�s�A
�
A	c��\R4h)z	_do_run())�NotImplementedErrorr_s&rr.�BaseS3TransferProcess._do_run�s
��!�+�.�.r!)r*r7)
r+r,r-r.r)r/r.r/r0�
__classcell__�r+r2s@@rr'r'�s�����
�"/�/r!r'c�baa�]tRtRtoV3RltRtRtRtRtRt	Rt
R	tR
tRt
VtV;t#)r�i�c�b<�\SV`V4WnW0nW@nWPnW`nR#)a�Submit GetObjectJobs to fulfill a download file request

:param transfer_config: Configuration for transfers.
:param client_factory: ClientFactory for creating S3 clients.
:param transfer_monitor: Monitor for notifying and retrieving state
    of transfer.
:param osutil: OSUtils object to use for os-related behavior when
    performing the transfer.
:param download_request_queue: Queue to retrieve download file
    requests.
:param worker_queue: Queue to submit GetObjectJobs for workers
    to perform.
N)r)r)r8rCr=r;r<)r(r�r�r�r�r�r�r+s&&&&&&&�rr)�GetObjectSubmitter.__init__�s/���,	����(� /��!1����'=�$�)�r!c��VPP4pV\8Xd\P	R4R#VPV4KQ \dpp\P	RTTRR7TPPTPT4TPPTP4Rp?K�Rp?ii;i)Tz#Submitter shutdown signal received.NzFException caught when submitting jobs for download file request %s: %s��exc_info)r;r�r�rTrU�_submit_get_object_jobs�	ExceptionrCr�rKr�)r(rX�es&  rr.�GetObjectSubmitter._do_runs����$(�$@�$@�$D�$D�$F�!�$��7����B�C��
��,�,�-B�C���

����3�)��!����&�&�7�7�)�5�5�q���&�&�2�2�)�5�5����

�s�A�C�A$C�Cc���VPV4pVPW4pW PP8dVP	W4R#VPWV4R#r)�	_get_size�_allocate_temp_filer8r%�_submit_single_get_object_job�_submit_ranged_get_object_jobs�r(rX�size�
temp_filenames&&  rr<�*GetObjectSubmitter._submit_get_object_jobs0sZ���~�~�3�4���0�0�1F�M�
��'�'�;�;�;��.�.�%�
�
�/�/�%�d�
r!c��VPpVfFVPP!RRVPRVP/VP
BR,pV#)N�Bucket�Key�
ContentLengthr )rPr*�head_objectrLrMrO)r(rXrPs&& rrA�GetObjectSubmitter._get_size<se��-�;�;�
�� � �L�L�4�4��,�3�3��)�-�-��(�2�2���	�M�
�r!c��VPPVP4pVPPW24V#r)r=�get_temp_filenamerN�allocaterEs&&& rrB�&GetObjectSubmitter._allocate_temp_fileFs9�����6�6�!�*�*�
�
�	
�����m�2��r!c
���VPVP^4VPVPVPVPV^VP
VPR7R#)r��rKrLrMrG�offsetrOrNN)�_notify_jobs_to_completerK�_submit_get_object_jobrLrMrOrN)r(rXrGs&&&rrC�0GetObjectSubmitter._submit_single_get_object_jobMsa��	
�%�%�&;�&G�&G��K��#�#�-�9�9�(�/�/�%�)�)�'��,�7�7�*�3�3�	$�	
r!c��VPPp\W44pVPVPV4\V4FvpWd,p\
WFV4pRV/p	V	PVP4VPVPVPVPVVV	VPR7Kx	R#)�RangerTN)
r8r&rrVrKr�r�updaterOrWrLrMrN)
r(rXrGrF�	part_size�	num_parts�irU�range_parameter�get_object_kwargss
&&&&      rrD�1GetObjectSubmitter._submit_ranged_get_object_jobs[s����)�)�=�=�	�'��8�	��%�%�!�-�-�y�	
��y�!�A��]�F�7��i��O�")�/� :���$�$�%:�%E�%E�F��'�'�1�=�=�,�3�3�)�-�-�+��,�.�7�7�
(�
�"r!c�N�VPP\R/VB4R#)Nr )r<rVr)r(�get_object_job_kwargss&,rrW�)GetObjectSubmitter._submit_get_object_jobts�������|�D�.C�D�Er!c�j�\PRVV4VPPW4R#)z3Notifying %s job(s) to complete for transfer_id %s.N)rTrUrCr)r(rKr�s&&&rrV�+GetObjectSubmitter._notify_jobs_to_completews0�����A���	
�
	
���?�?��	
r!)r;r=r8rCr<)r+r,r-r.r)r.r<rArBrCrDrWrVr/r0r4r5s@@rr�r��s8����*�:�.
���
��2F�
�
r!r�c�laa�]tRtRto^t^],tV3RltRtRt	Rt
RtRtRt
R	tVtV;t#)
r�i�c�V<�\SV`V4WnW nW0nW@nR#)a�Fulfills GetObjectJobs

Downloads the S3 object, writes it to the specified file, and
renames the file to its final location if it completes the final
job for a particular transfer.

:param queue: Queue for retrieving GetObjectJob's
:param client_factory: ClientFactory for creating S3 clients
:param transfer_monitor: Monitor for notifying
:param osutil: OSUtils object to use for os-related behavior when
    performing the transfer.
N)r)r)�_queuer7rCr=)r(r�r�r�r�r+s&&&&&�rr)�GetObjectWorker.__init__�s(���	����(���-��!1���r!c�*�VPP4pV\8Xd\P	R4R#VP
P
VP4'gVPV4M\P	RV4VP
PVP4p\P	RVVP4V'dK�VPVPVPVP4EK)Tz Worker shutdown signal received.NzBSkipping get object job %s because there was a previous exception.z%%s jobs remaining for transfer_id %s.)
rir�r�rTrUrCr�rK�_run_get_object_jobr�_finalize_downloadrGrN)r(�job�	remainings&  rr.�GetObjectWorker._do_run�s�����+�+�/�/�#�C��o�%����?�@���)�)�7�7����H�H��(�(��-����!���
�.�.�B�B�����I�
�L�L�7�����
�
�9��'�'��O�O�S�%6�%6����r!c�H�VPVPVPVPVPVP
R7R# \dKp\PRTTRR7TPPTPT4Rp?R#Rp?ii;i))rLrMrGrOrUzBException caught when downloading object for get object job %s: %sTr:N)�_do_get_objectrLrMrGrOrUr=rTrUrCr�rK)r(rnr>s&& rrl�#GetObjectWorker._run_get_object_job�s���	H�����z�z��G�G�!�/�/��>�>��z�z�
 �
���	H��L�L�(����
�
�
�"�"�3�3�C�O�O�Q�G�G��	H�s�AA�B!�?B�B!c
�V�Rp\VP4F>pVPP!RRVRV/VBpVP	WEVR,4R#	\V4h \
d9p	\PRT	T^,TPRR7T	pRp	?	K�Rp	?	ii;i)NrJrK�BodyzCRetrying exception caught (%s), retrying request, (attempt %s / %s)Tr:r )	r��
_MAX_ATTEMPTSr*�
get_object�_write_to_filer
rTrUr
)
r(rLrMrOrGrU�last_exceptionr^�responser>s
&&&&&&    rrr�GetObjectWorker._do_get_object�s������t�)�)�*�A�
#��<�<�2�2��!��'*��.8����#�#�M�8�F�;K�L��
+�"#�>�2�2��0�	
#����:����E��&�&�!�
��"#���	
#�s�9A%�%B(�0-B#�#B(c��aa�\VR4;_uu_4pVPV4\VV3RlR4pVFpVPV4K	RRR4R# +'giR#;i)zrb+c�:<�SPSP4#r)�read�
_IO_CHUNKSIZE)�bodyr(s��r�<lambda>�0GetObjectWorker._write_to_file.<locals>.<lambda>�s���$�)�)�D�,>�,>�"?r!r!N)�open�seek�iter�write)r(rNrUr��f�chunks�chunksf&&f   rrx�GetObjectWorker._write_to_file�sN���
�(�E�
"�
"�a�
�F�F�6�N��?��E�F�������� �#�
"�
"�
"�s�=A�A/	c���VPPV4'dVPPV4MVP	WV4VPPV4R#r)rCr�r=�remove_file�_do_file_renamer�)r(rKrGrNs&&&&rrm�"GetObjectWorker._finalize_download�sO���!�!�/�/��<�<��L�L�$�$�]�3�� � ��X�F����*�*�;�7r!c���VPPW#4R# \dBpTPP	Y4TPPT4Rp?R#Rp?ii;ir)r=�rename_filer=rCr�r�)r(rKrGrNr>s&&&& rr��GetObjectWorker._do_file_rename�sR��	4��L�L�$�$�]�=���	4��"�"�3�3�K�C��L�L�$�$�]�3�3��	4�s��A+�6A&�&A+)r7r=rirC)r+r,r-r.rvrrr)r.rlrrrxrmr�r/r0r4r5s@@rr�r��s>�����M���F�M��&�6H�&3�*�8�4�4r!r�rJ)rKrLrMrGrOrUrN)8r��collections�
contextlib�loggingr9rr?�copyr�botocore.sessionr��botocore.configr�s3transfer.compatrr�s3transfer.constantsrrr�s3transfer.exceptionsr	r
�s3transfer.futuresrr�s3transfer.utilsr
rrrrr�	getLoggerr+rTr��
namedtuplerr�contextmanagerrrr#r4r�r�r6r�r�r��register�Processr'r�r�r r!r�<module>r�sU��u�n����
����"�1�N�N�F�C���
�	�	�8�	$����
"�,�,���
���%�%�����"���3��3�8�;�;�,C�C�L-
� 2�-
�`"�.�"�*J�J�2]O�]O�@-*�-*�`	�[�	���� 1�?�C�/�O�3�3�/�6D
�.�D
�No4�+�o4r!

Youez - 2016 - github.com/yon3zu
LinuXploit