AlkantarClanX12

Your IP : 18.224.31.82


Current Path : /opt/alt/python312/lib64/python3.12/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/multiprocessing/__pycache__/pool.cpython-312.opt-1.pyc

�

�Q�f����ddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZm
Z
ddlmZdZd	Zd
ZdZej(�Zd�Zd
�ZGd�de�ZGd�d�Zd�ZGd�de�Z		d#d�Zd�ZGd�de�Z Gd�de!�Z"Gd�de!�Z#e#Z$Gd�de#�Z%Gd�de!�Z&Gd �d!e&�Z'Gd"�de"�Z(y)$�Pool�
ThreadPool�N�)�util)�get_context�TimeoutError)�wait�INIT�RUN�CLOSE�	TERMINATEc�$�tt|��S�N)�list�map��argss �;/opt/alt/python312/lib64/python3.12/multiprocessing/pool.py�mapstarr/s����T�
���c�L�ttj|d|d��S)Nrr)r�	itertools�starmaprs r�starmapstarr2s"���	�!�!�$�q�'�4��7�3�4�4rc��eZdZd�Zd�Zy)�RemoteTracebackc��||_yr��tb)�selfrs  r�__init__zRemoteTraceback.__init__:s	����rc��|jSrr�r s r�__str__zRemoteTraceback.__str__<s���w�w�rN)�__name__�
__module__�__qualname__r!r$�rrrr9s���rrc��eZdZd�Zd�Zy)�ExceptionWithTracebackc��tjt|�||�}dj|�}||_d|z|_y)N�z

"""
%s""")�	traceback�format_exception�type�join�excr)r r1rs   rr!zExceptionWithTraceback.__init__@s:��
�
'�
'��S�	�3��
;��
�W�W�R�[����� �2�%��rc�>�t|j|jffSr)�rebuild_excr1rr#s r�
__reduce__z!ExceptionWithTraceback.__reduce__Es���T�X�X�t�w�w�/�/�/rN)r%r&r'r!r4r(rrr*r*?s��&�
0rr*c�&�t|�|_|Sr)r�	__cause__)r1rs  rr3r3Hs��#�B�'�C�M��Jrc�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�MaybeEncodingErrorzVWraps possible unpickleable errors, so they can be
    safely sent through the socket.c���t|�|_t|�|_tt|�|j|j�yr)�reprr1�value�superr8r!)r r1r;�	__class__s   �rr!zMaybeEncodingError.__init__Ts3�����9����%�[��
�
� �$�0����4�:�:�Frc�<�d|j�d|j�d�S)NzError sending result: 'z'. Reason: '�')r;r1r#s rr$zMaybeEncodingError.__str__Ys��=A�Z�Z�=A�X�X�G�	Grc�<�d|jj�d|�d�S)N�<z: �>)r=r%r#s r�__repr__zMaybeEncodingError.__repr__]s��!�^�^�4�4�d�;�;r)r%r&r'�__doc__r!r$rC�
__classcell__�r=s@rr8r8Ps���'�G�
G�<rr8c�|�|�/t|t�r|dk\stdj|���|j}|j
}t
|d�r4|jj�|jj�|�||�d}|�|r`||kr[	|�}	|	�tjd�n;|	\}
}}}
}	d||
i|��f}	||
||f�dx}	x}
x}x}x}
}|dz
}|��S|r||kr�[tjd
|z�y#ttf$rtjd�Y�?wxYw#t$r.}|r|turt!||j"�}d|f}Yd}~��d}~wwxYw#t$r>}t%||d�}tjd	|z�||
|d|ff�Yd}~��d}~wwxYw)NrzMaxtasks {!r} is not valid�_writerrz)worker got EOFError or OSError -- exitingzworker got sentinel -- exitingTFz0Possible encoding error while sending result: %szworker exiting after %d tasks)�
isinstance�int�AssertionError�format�put�get�hasattrrH�close�_reader�EOFError�OSErrorr�debug�	Exception�_helper_reraises_exceptionr*�
__traceback__r8)�inqueue�outqueue�initializer�initargs�maxtasks�wrap_exceptionrMrN�	completed�task�job�i�funcr�kwds�result�e�wrappeds                  r�workerrgas�����z�(�C�'@�+3�q�=��9�@�@��J�K�K�
�,�,�C�
�+�+�C��w�	�"������������ ����X���I�
�
�x�I��,@�	��5�D�
�<��J�J�7�8��#'� ��Q��d�D�	 ��D�$�/�$�/�0�F�
	,���a�� �!�48�7��7�s�7�V�7�d�7�T�D��Q��	�7�
�x�I��,@�8	�J�J�.��:�;��3�'�"�	��J�J�B�C��	���	 ��$�.H�"H�*�1�a�o�o�>���Q�Z�F��	 ���	,�(��F�1�I�6�G��J�J�I���
���a�%��)�*�+�+��		,�sB�D�
D:�E4�$D7�6D7�:	E1�$E,�,E1�4	F;�=4F6�6F;c��|�)z@Pickle-able helper function for use by _guarded_task_generation.r()�exs rrVrV�s��
�Hrc�2��eZdZdZdd��fd�
Z�fd�Z�xZS)�
_PoolCachez�
    Class that implements a cache for the Pool class that will notify
    the pool management threads every time the cache is emptied. The
    notification is done by the use of a queue that is provided when
    instantiating the cache.
    N��notifierc�2��||_t�|�|i|��yr)rmr<r!)r rmrrcr=s    �rr!z_PoolCache.__init__�s��� ��
�
���$�'�$�'rc�`��t�|�|�|s|jjd�yyr)r<�__delitem__rmrM)r �itemr=s  �rrpz_PoolCache.__delitem__�s,���
���D�!���M�M���d�#�r)r%r&r'rDr!rprErFs@rrkrk�s����+/�(�
$�
$rrkc��eZdZdZdZed��Z		d(d�Zeje
fd�Zd�Zd	�Z
ed
��Zed��Zd�Zed
��Zed��Zd�Zd�Zdifd�Zd)d�Zd)d�Z		d*d�Zd�Zd+d�Zd+d�Zdiddfd�Z		d*d�Z		d*d�Zed)d��Ze d��Z!ed��Z"ed��Z#ed��Z$d �Z%d!�Z&d"�Z'd#�Z(ed$��Z)e d%��Z*d&�Z+d'�Z,y),rzS
    Class which supports an async version of applying functions to arguments.
    Tc�&�|j|i|��Sr��Process)�ctxrrcs   rruzPool.Process�s���s�{�{�D�)�D�)�)rNr(c��g|_t|_|xs
t�|_|j�t
j�|_|jj�|_	t|j��|_||_||_
||_|�tj �xsd}|dkrt#d��|� t%|t&�r|dkrt#d��|�t)|�st+d��||_	|j/�|j9�}t;j<t>j@|j|j|j|jB|j,|j|jD|jF|j|j|j|jH||jf��|_%d|jJ_&tN|jJ_|jJjQ�t;j<t>jR|j|jT|jF|j|jf��|_+d|jV_&tN|jV_|jVjQ�t;j<t>jX|jF|jZ|jf��|_.d|j\_&tN|j\_|j\jQ�t_j`||jb|j|jD|jF|j|j|jJ|jV|j\|jf	d	�
�|_2tN|_y#t0$rQ|jD]}|j2��|j5��!|jD]}|j7���wxYw)Nrlrz&Number of processes must be at least 1rz/maxtasksperchild must be a positive int or Nonezinitializer must be a callable��targetrT�)r�exitpriority)3�_poolr
�_stater�_ctx�
_setup_queues�queue�SimpleQueue�
_taskqueue�_change_notifierrk�_cache�_maxtasksperchild�_initializer�	_initargs�os�	cpu_count�
ValueErrorrIrJ�callable�	TypeError�
_processes�_repopulate_poolrU�exitcode�	terminater0�_get_sentinels�	threading�Threadr�_handle_workersru�_inqueue�	_outqueue�_wrap_exception�_worker_handler�daemonr�start�
_handle_tasks�
_quick_put�
_task_handler�_handle_results�
_quick_get�_result_handlerr�Finalize�_terminate_pool�
_terminate)r �	processesrZr[�maxtasksperchild�context�p�	sentinelss        rr!z
Pool.__init__�sL����
�����,�{�}��	������+�+�-���!%�	�	� 5� 5� 7��� �$�*?�*?�@���!1���'���!���������+�!�I��q�=��E�F�F��'��.��4�8H�A�8M� �!R�S�S��"�8�K�+@��<�=�=�#���	��!�!�#��'�'�)�	�(�/�/��'�'��+�+�t����	�	�4�<�<��/�/�4�:�:�t�}�}�d�n�n��#�#�T�^�^�T�5K�5K��&�&�	�4�3H�3H�J� ���'+����#�&)����#����"�"�$�'�-�-��%�%��/�/�4�?�?�D�N�N��*�*�d�k�k�+����
%)����!�$'����!���� � �"�(�/�/��'�'��.�.�$�/�/�4�;�;�?� ���'+����#�&)����#����"�"�$��-�-��$�&�&��/�/�4�=�=�$�.�.�$�*�*��'�'��)=�)=�t�?Q�?Q��&�&����5���������]�	��Z�Z���:�:�%��K�K�M� ��Z�Z������ ��
	�s�
O'�'$Q�5Qc��|j|k(r<|d|��t|��t|dd��|jj	d�yyy)Nz&unclosed running multiprocessing pool )�sourcer�)r}�ResourceWarning�getattrr�rM)r �_warnrs   r�__del__zPool.__del__
sT���;�;�#���:�4�(�C�!�$�
0��t�/��6�B��%�%�)�)�$�/�C�rc
��|j}d|j�d|j�d|j�dt	|j
��d�	S)NrA�.z state=z pool_size=rB)r=r&r'r}�lenr|)r �clss  rrCz
Pool.__repr__sQ���n�n���C�N�N�#�1�S�%5�%5�$6�7����
�&� ����_�-�Q�0�	1rc�j�|jjg}|jjg}g|�|�Sr)r�rQr�)r �task_queue_sentinels�self_notifier_sentinelss   rr�zPool._get_sentinelss<�� $��� 6� 6�7��#'�#8�#8�#@�#@�"A��@�%�@�(?�@�@rc�X�|D�cgc]}t|d�r|j��c}Scc}w)N�sentinel)rOr�)�workersrgs  r�_get_worker_sentinelszPool._get_worker_sentinelss:���8��%+�"�6�:�6�����8�	8��8s�'c���d}ttt|���D]A}||}|j��t	j
d|z�|j
�d}||=�C|S)z�Cleanup after any worker processes which have exited due to reaching
        their specified lifetime.  Returns True if any workers were cleaned up.
        F�cleaning up worker %dT)�reversed�ranger�r�rrTr0)�pool�cleanedrargs    r�_join_exited_workerszPool._join_exited_workers!sb��
���%��D�	�*�+�A��!�W�F����*��
�
�2�Q�6�7����
�����G�,��rc��|j|j|j|j|j|j
|j|j|j|j|j�
Sr)�_repopulate_pool_staticr~rur�r|r�r�r�r�r�r�r#s rr�zPool._repopulate_pool1s_���+�+�D�I�I�t�|�|�,0�O�O�,0�J�J��
�
�,0�N�N�D�<M�<M�,0�N�N�,0�,B�,B�,0�,@�,@�
B�	Brc
�"�t|t|�z
�D]u}
||t||||||	f��}|jj	dd�|_d|_|j
�|j|�tjd��wy)z�Bring the number of pool processes up to the specified number,
        for use after reaping workers which have exited.
        rxru�
PoolWorkerTzadded workerN)
r�r�rg�name�replacer�r��appendrrT)rvrur�r�rXrYrZr[r�r]ra�ws            rr�zPool._repopulate_pool_static:s���y�3�t�9�,�-�A���F�%�x�)�&�(8�,�.�/�A�
�V�V�^�^�I�|�<�A�F��A�H�
�G�G�I��K�K��N��J�J�~�&�.rc
�l�tj|�rtj||||||||||	�
yy)zEClean up any exited workers and start replacements for them.
        N)rr�r�)
rvrur�r�rXrYrZr[r�r]s
          r�_maintain_poolzPool._maintain_poolMs=���$�$�T�*��(�(��g�y�$�)0�(�K�)1�3C�)7�
9�+rc��|jj�|_|jj�|_|jjj
|_|jjj|_	yr)
r~r�r�r�rH�sendr�rQ�recvr�r#s rrzPool._setup_queuesYsX���	�	�-�-�/��
����.�.�0����-�-�/�/�4�4����.�.�0�0�5�5��rc�@�|jtk7rtd��y)NzPool not running)r}rr�r#s r�_check_runningzPool._check_running_s���;�;�#���/�0�0�rc�D�|j|||�j�S)zT
        Equivalent of `func(*args, **kwds)`.
        Pool must be running.
        )�apply_asyncrN)r rbrrcs    r�applyz
Pool.applycs"��
����d�D�1�5�5�7�7rc�N�|j||t|�j�S)zx
        Apply `func` to each element in `iterable`, collecting the results
        in a list that is returned.
        )�
_map_asyncrrN�r rb�iterable�	chunksizes    rrzPool.mapjs"��
���t�X�w�	�B�F�F�H�Hrc�N�|j||t|�j�S)z�
        Like `map()` method but the elements of the `iterable` are expected to
        be iterables as well and will be unpacked as arguments. Hence
        `func` and (a, b) becomes func(a, b).
        )r�rrNr�s    rrzPool.starmapqs"�����t�X�{�I�F�J�J�L�Lrc�6�|j||t|||�S)z=
        Asynchronous version of `starmap()` method.
        )r�r�r rbr�r��callback�error_callbacks      r�
starmap_asynczPool.starmap_asyncys"��
���t�X�{�I�'��9�	9rc#�K�	d}t|�D]\}}||||fif���y#t$r}|dzt|fif��Yd}~yd}~wwxYw�w)z�Provides a generator of tasks for imap and imap_unordered with
        appropriate handling for iterables which throw exceptions during
        iteration.���rN)�	enumeraterUrV)r �
result_jobrbr�ra�xres       r�_guarded_task_generationzPool._guarded_task_generation�s`����	J��A�!�(�+���1�!�1�d�Q�D�"�5�5�,���	J��q��s�$>���b�I�I��	J�s)�A�$�A�	A�A�A�A�Ac���|j�|dk(rOt|�}|jj|j	|j
||�|jf�|S|dkrtdj|���tj|||�}t|�}|jj|j	|j
t|�|jf�d�|D�S)zP
        Equivalent of `map()` -- can be MUCH slower than `Pool.map()`.
        rzChunksize must be 1+, not {0:n}c3�.K�|]
}|D]}|����y�wrr(��.0�chunkrqs   r�	<genexpr>zPool.imap.<locals>.<genexpr>������?�f�U���D��D�f���)r��IMapIteratorr�rMr��_job�_set_lengthr�rLr�
_get_tasksr�r rbr�r�rd�task_batchess      r�imapz	Pool.imap�s���	
������>�!�$�'�F��O�O����1�1�&�+�+�t�X�N��&�&��
�
�M��1�}� �5�<�<�!�#�$�$� �?�?�4��9�E�L�!�$�'�F��O�O����1�1�&�+�+�29�2>�@��&�&�	�
�@�f�?�?rc���|j�|dk(rOt|�}|jj|j	|j
||�|jf�|S|dkrtdj|���tj|||�}t|�}|jj|j	|j
t|�|jf�d�|D�S)zL
        Like `imap()` method but ordering of results is arbitrary.
        rzChunksize must be 1+, not {0!r}c3�.K�|]
}|D]}|����y�wrr(r�s   rr�z&Pool.imap_unordered.<locals>.<genexpr>�r�r�)r��IMapUnorderedIteratorr�rMr�r�r�r�rLrr�rr�s      r�imap_unorderedzPool.imap_unordered�s���	
������>�*�4�0�F��O�O����1�1�&�+�+�t�X�N��&�&��
�
�M��1�}� �5�<�<�Y�G�I�I��?�?�4��9�E�L�*�4�0�F��O�O����1�1�&�+�+�29�2>�@��&�&�	�
�@�f�?�?rc��|j�t|||�}|jj|jd|||fgdf�|S)z;
        Asynchronous version of `apply()` method.
        rN)r��ApplyResultr�rMr�)r rbrrcr�r�rds       rr�zPool.apply_async�sL��
	
�����T�8�^�<�������v�{�{�A�t�T�4�@�A�4�H�I��
rc�6�|j||t|||�S)z9
        Asynchronous version of `map()` method.
        )r�rr�s      r�	map_asynczPool.map_async�s"��
���t�X�w�	�8���	rc��|j�t|d�st|�}|�5tt	|�t	|j
�dz�\}}|r|dz
}t	|�dk(rd}tj|||�}t||t	|�||��}	|jj|j|	j||�df�|	S)zY
        Helper function to implement map, starmap and their async counterparts.
        �__len__N�rr�r�)
r�rOr�divmodr�r|rr��	MapResultr�rMr�r�)
r rbr��mapperr�r�r��extrar�rds
          rr�zPool._map_async�s���
	
�����x��+��H�~�H���%�c�(�m�S����_�q�5H�I��I�u���Q��	��x�=�A���I����t�X�y�A���4��C��M�8�*8�:��������-�-�f�k�k�.4�.:�<��	
�	
��
rc��t||��|j�s"|j�|j�s�!yy)N)�timeout)r	�emptyrN)r��change_notifierrs   r�_wait_for_updateszPool._wait_for_updates�s2���Y��(�!�'�'�)����!�"�'�'�)rc��tj�}|jtk(s|r~|jtk7rk|j|||||||	|
||�
g|j
|��|
�}|j||�|jtk(r�U|r|jtk7r�k|jd�tjd�y)Nzworker handler exiting)r��current_threadr}rr
r�r�rrMrrT)r��cache�	taskqueuervrur�r�rXrYrZr[r�r]r�r�thread�current_sentinelss                 rr�zPool._handle_workers�s���
�)�)�+���m�m�s�"�u����)�1K����s�G�Y��g�'��h�/��
A�!O�#�";�";�D�"A� N�I� N���!�!�"3�_�E��m�m�s�"�u����)�1K�	�
�
�d���
�
�+�,rc�0�tj�}t|jd�D]}\}}d}	|D]5}|jt
k7rt
jd�n>	||��7|r)t
jd�|r|dnd}||dz�	dx}x}}
�v	dx}x}}
nt
jd�	t
jd�|jd�t
jd	�|D]
}|d��	t
jd�y#t$r;}	|dd\}
}	||
j|d|	f�n#t$rYnwxYwYd}	~	��+d}	~	wwxYw#dx}x}}
wxYw#t$rt
jd
�Y��wxYw)Nz'task handler found thread._state != RUN�Fzdoing set_length()rr�ztask handler got sentinelz/task handler sending sentinel to result handlerz(task handler sending sentinel to workersz/task handler got OSError when sending sentinelsztask handler exiting)
r�r	�iterrNr}rrrTrU�_set�KeyErrorrMrS)
rrMrYr�r
r�taskseq�
set_lengthr_rer`�idxr�s
             rr�zPool._handle_taskss����)�)�+��#'�	�
�
�t�#<��G�Z��D�
,�#�D��}�}��+��
�
�#L�M��!��D�	�$�"��
�
�#7�8�)-�d�1�g�2��"�3��7�+��(,�+��+�w���'+�+��+�w��1$=�4
�J�J�2�3�
	J��J�J�H�I��L�L���
�J�J�A�B����D�	��
	
�
�
�)�*��=%�!�#'���8���S�!�!�#�J�O�O�C�%���<��'�!� �!���	!��(,�+��+�w����	J��J�J�H�I�	J�sl�/E)�$D"�,-E)�A
E4�"	E&�+E!�4E�E!�	E	�E!�E	�E!�E)�!E&�&E)�)E1�4F�Fc���tj�}		|�}|jtk7rt	j
d�n;|�t	j
d�n#|\}}}	||j||�dx}x}}�l|rk|jtk7rX	|�}|�t	j
d��5|\}}}	||j||�dx}x}}|r|jtk7r�Xt|d�rIt	j
d�	td�D]%}|jj�sn	|��'t	j
dt|�|j�y#ttf$rt	j
d�YywxYw#t$rY��*wxYw#ttf$rt	j
d�YywxYw#t$rY��wxYw#ttf$rY��wxYw)	Nz.result handler got EOFError/OSError -- exitingz,result handler found thread._state=TERMINATEzresult handler got sentinelz&result handler ignoring extra sentinelrQz"ensuring that outqueue is not full�
z7result handler exiting: len(cache)=%s, thread._state=%s)r�r	rSrRrrTr}rrrr
rOr�rQ�pollr�)rYrNr
rr_r`ra�objs        rr�zPool._handle_results=s����)�)�+���
��u��
�}�}��#��
�
�I�J���|��
�
�8�9���K�C��C�
��c�
����3�'� $�#�D�#�3��+�.��
�
��2�
��u��
�|��
�
�C�D���K�C��C�
��c�
����3�'� $�#�D�#�3����
�
��2�"�8�Y�'��J�J�;�<�
��r��A�#�+�+�0�0�2���E�#�	
�
�
�L��%�j�&�-�-�	)��e�X�&�
��
�
�K�L��
�� �
��
���X�&�
��
�
�K�L��
���
��
���X�&�
��
�sY�E/�&F�F)�>G�3G#�/$F�F�	F&�%F&�)$G�G�	G �G �#G5�4G5c#�tK�t|�}	ttj||��}|sy||f���)�wr)r�tupler�islice)rb�it�sizer�s    rr�zPool._get_tasksys=����
�"�X����i�&�&�r�4�0�1�A�����)�O�	�s�68c��td��)Nz:pool objects cannot be passed between processes or pickled)�NotImplementedErrorr#s rr4zPool.__reduce__�s��!�J��	rc���tjd�|jtk(r<t|_t|j
_|jjd�yy)Nzclosing pool)rrTr}rrr�r�rMr#s rrPz
Pool.close�sH���
�
�>�"��;�;�#���D�K�*/�D� � �'��!�!�%�%�d�+�rc�d�tjd�t|_|j	�y)Nzterminating pool)rrTr
r}r�r#s rr�zPool.terminate�s ���
�
�%�&�������rc��tjd�|jtk(rt	d��|jt
tfvrt	d��|jj�|jj�|jj�|jD]}|j��y)Nzjoining poolzPool is still runningzIn unknown state)rrTr}rr�rr
r�r0r�r�r|)r r�s  rr0z	Pool.join�s����
�
�>�"��;�;�#���4�5�5�
�[�[��	� 2�
2��/�0�0����!�!�#������!����!�!�#����A�
�F�F�H�rc�p�tjd�|jj�|j	�rw|j
j
�r\|j
j�tjd�|j	�r|j
j
�r�Zyyyy)Nz7removing tasks from inqueue until task handler finishedr)
rrT�_rlock�acquire�is_aliverQrr��time�sleep)rX�task_handlerrs   r�_help_stuff_finishzPool._help_stuff_finish�s}��	
�
�
�L�M������ ��#�#�%�'�/�/�*>�*>�*@��O�O� � �"��J�J�q�M��#�#�%�'�/�/�*>�*>�*@�%�*@�%rc
�d�tjd�t|_|j	d�t|_tjd�|j||t
|��|j�st
|	�dk7rtd��t|_|j	d�|j	d�tjd�tj�|ur|j�|rHt|dd�r9tjd�|D]}
|
j��|
j��!tjd�tj�|ur|j�tjd	�tj�|ur|j�|rpt|dd�r`tjd
�|D]E}
|
j�s�tjd|
jz�|
j��Gyyy)Nzfinalizing poolz&helping task handler/workers to finishrz/Cannot have cache with result_handler not alivezjoining worker handlerr�zterminating workerszjoining task handlerzjoining result handlerzjoining pool workersr�)rrTr
r}rMr+r�r'rKr�r	r0rOr�r��pid)r�rrXrYr�r�worker_handlerr*�result_handlerr
r�s           rr�zPool._terminate_pool�s���	
�
�
�$�%�
!*������D�!�'����
�
�;�<����w��c�$�i�@��'�'�)��E�
�a�� �A�C�
C�!*������D�!����T��	
�
�
�+�,��#�#�%�^�;����!��G�D��G�[�1��J�J�,�-����:�:�%��K�K�M��	
�
�
�)�*��#�#�%�\�9������
�
�+�,��#�#�%�^�;����!��G�D��G�[�1��J�J�-�.����:�:�<��J�J�6����>�?��F�F�H�	�2�4rc�&�|j�|Sr)r�r#s r�	__enter__zPool.__enter__�s�������rc�$�|j�yr)r�)r �exc_type�exc_val�exc_tbs    r�__exit__z
Pool.__exit__�s�����r)NNr(NNr)NNN)r)-r%r&r'rDr��staticmethodrur!�warnings�warnrr�rCr�r�r�r�r�r�rr�r�rrr�r�r�r�r�r�r�r�classmethodr�r�r�r�r4rPr�r0r+r�r1r6r(rrrr�s�����O��*��*�CE�04�O�f%�M�M�s�0�1�A�
�8��8��
��
�B��'��'�$�	9��	9�6�1� "��8�I�M�FJ��9�	J�@�:@�8&(�b�4���BF���KO���:�"��"�
�-��-�(�++��++�Z�9)��9)�v�����
,��

������3��3�j�rc�X�eZdZd�Zd�Zd�Zdd�Zdd�Zd�Ze	e
j�Zy)	r�c���||_tj�|_t	t
�|_|j|_||_||_	||j|j<yr)
r|r��Event�_event�next�job_counterr�r��	_callback�_error_callback)r r�r�r�s    rr!zApplyResult.__init__�sO����
��o�o�'�����%��	��k�k���!���-���!%����D�I�I�rc�6�|jj�Sr)r>�is_setr#s r�readyzApplyResult.ready�s���{�{�!�!�#�#rc�n�|j�stdj|���|jS)Nz{0!r} not ready)rEr�rL�_successr#s r�
successfulzApplyResult.successful�s,���z�z�|��.�5�5�d�;�<�<��}�}�rNc�:�|jj|�yr)r>r	�r rs  rr	zApplyResult.wait�s��������!rc��|j|�|j�st�|jr|jS|j�r)r	rErrG�_valuerJs  rrNzApplyResult.get�s8���	�	�'���z�z�|����=�=��;�;���+�+�rc�^�|\|_|_|jr'|jr|j|j�|jr'|js|j|j�|jj�|j|j=d|_yr)	rGrLrArBr>�setr�r�r|�r rars   rrzApplyResult._setss��%(�"��
�t�{��>�>�d�m�m��N�N�4�;�;�'�����
�
�� � ����-��������K�K��	�	�"���
rr)
r%r&r'r!rErHr	rNrr:�types�GenericAlias�__class_getitem__r(rrr�r��s3��&�$��
"���$�E�$6�$6�7�rr�c��eZdZd�Zd�Zy)rc��tj||||��d|_dg|z|_||_|dkr9d|_|jj�|j|j=y||zt||z�z|_y)Nr�Tr)r�r!rGrL�
_chunksize�_number_leftr>rNr�r��bool)r r�r��lengthr�r�s      rr!zMapResult.__init__s������T�4��,:�	�	<���
��f�v�o���#�����>� !�D���K�K�O�O�����D�I�I�&� &�	� 1�D��)�9K�4L� L�D�rc��|xjdzc_|\}}|r�|jr�||j||jz|dz|jz|jdk(r`|jr|j	|j�|j
|j=|jj�d|_	yy|s|jrd|_||_|jdk(r`|jr|j|j�|j
|j=|jj�d|_	yy)NrrF)rVrGrLrUrAr�r�r>rNr|rB)r ra�success_result�successrds     rrzMapResult._set)s�����Q���(�����t�}�}�CI�D�K�K��$�/�/�)�1�Q�3����*?�@�� � �A�%��>�>��N�N�4�;�;�/��K�K��	�	�*������!�!��
�&��t�}�}� %��
�$���� � �A�%��'�'��(�(����5��K�K��	�	�*������!�!��
�
&rN)r%r&r'r!rr(rrrrs
��M�"rrc�0�eZdZd�Zd�Zdd�ZeZd�Zd�Zy)r�c�B�||_tjtj��|_tt�|_|j|_tj�|_d|_d|_
i|_||j|j<y)Nr)r|r��	Condition�Lock�_condr?r@r�r��collections�deque�_items�_index�_length�	_unsorted)r r�s  rr!zIMapIterator.__init__Gsp����
��(�(����)9�:��
���%��	��k�k���!�'�'�)������������!%����D�I�I�rc��|Srr(r#s r�__iter__zIMapIterator.__iter__Rs���rNc���|j5	|jj�}ddd�\}}|r|S|�#t$r�|j|j
k(rd|_td�|jj|�	|jj�}n;#t$r/|j|j
k(rd|_td�td�wxYwY��wxYw#1swY��xYwr)
r`rc�popleft�
IndexErrorrdrer|�
StopIterationr	r)r rrqr[r;s     rr?zIMapIterator.nextUs���
�Z�Z�

1��{�{�*�*�,��� ������L����!�
1��;�;�$�,�,�.�!%�D�J�'�T�1��
�
����(�1��;�;�.�.�0�D��!�1��{�{�d�l�l�2�%)��
�+��5�&�D�0�	1���

1���Z�s?�C$�<�AC!�B#�"C!�#8C�C!�C$� C!�!C$�$C-c��|j5|j|k(r�|jj|�|xjdz
c_|j|jvrn|jj|j�}|jj|�|xjdz
c_|j|jvr�n|jj
�n||j|<|j|jk(r|j|j=d|_
ddd�y#1swYyxYw�Nr)r`rdrcr�rf�pop�notifyrer�r�r|rOs   rrzIMapIterator._setms���
�Z�Z��{�{�a�����"�"�3�'����q� ���k�k�T�^�^�3��.�.�,�,�T�[�[�9�C��K�K�&�&�s�+��K�K�1�$�K��k�k�T�^�^�3��
�
�!�!�#�$'����q�!��{�{�d�l�l�*��K�K��	�	�*�!��
��Z�Z�s�CD=�A!D=�=Ec��|j5||_|j|jk(r8|jj�|j|j
=d|_ddd�y#1swYyxYwr)r`rerdrpr�r�r|)r rXs  rr�zIMapIterator._set_length~sQ��
�Z�Z�!�D�L��{�{�d�l�l�*��
�
�!�!�#��K�K��	�	�*�!��
��Z�Z�s�AA/�/A8r)	r%r&r'r!rhr?�__next__rr�r(rrr�r�Es"��	&���,�H�"�""rr�c��eZdZd�Zy)r�c�H�|j5|jj|�|xjdz
c_|jj	�|j|j
k(r|j|j=d|_ddd�y#1swYyxYwrn)	r`rcr�rdrprer�r�r|rOs   rrzIMapUnorderedIterator._set�sj��
�Z�Z��K�K���s�#��K�K�1��K��J�J�����{�{�d�l�l�*��K�K��	�	�*�!��
�
�Z�Z�s�BB�B!N)r%r&r'rr(rrr�r��s��"rr�c�Z�eZdZdZed��Zd
d�Zd�Zd�Zed��Z	ed��Z
d	�Zy)rFc��ddlm}||i|��S)Nrrt)�dummyru)rvrrcrus    rruzThreadPool.Process�s��"���%��%�%rNc�4�tj||||�yr)rr!)r r�rZr[s    rr!zThreadPool.__init__�s���
�
�d�I�{�H�=rc���tj�|_tj�|_|jj|_|jj|_yr)r�r�r�r�rMr�rNr�r#s rrzThreadPool._setup_queues�sD���)�)�+��
��*�*�,����-�-�+�+����.�.�,�,��rc�0�|jjgSr)r�rQr#s rr�zThreadPool._get_sentinels�s���%�%�-�-�.�.rc��gSrr()r�s rr�z ThreadPool._get_worker_sentinels�s���	rc��		|jd���#tj$rYnwxYwt|�D]}|j	d��y)NF)�block)rNr��Emptyr�rM)rXr*rras    rr+zThreadPool._help_stuff_finish�sM��	�����%��(����{�{�	��	���t��A��K�K���s��,�,c�.�tj|�yr)r(r))r r�rrs    rrzThreadPool._wait_for_updates�s���
�
�7�r)NNr()r%r&r'r�r7rur!rr�r�r+rr(rrrr�sU���O��&��&�>�-�/���������r)Nr(NF))�__all__rarr�r�r�r(r-rPr8r,rrr�
connectionr	r
rrr
�countr@rrrUrr*r3r8rgrV�dictrk�objectrr��AsyncResultrr�r�rr(rr�<module>r�s���<�
 ����	��������'���������	��i�o�o����5��i��0�0��<��<�"GK��+<�Z
�$��$�.v�6�v�x)8�&�)8�V��%"��%"�V?"�6�?"�J	"�L�	"�$��$r