Your IP : 18.117.93.183


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-2.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�,��eZdZ	�fd�Zd�Zd�Z�xZS)�MaybeEncodingErrorc���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'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�hasattrrG�close�_reader�EOFError�OSErrorr�debug�	Exception�_helper_reraises_exceptionr*�
__traceback__r8)�inqueue�outqueue�initializer�initargs�maxtasks�wrap_exceptionrLrM�	completed�task�job�i�funcr�kwds�result�e�wrappeds                  r�workerrfas�����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��	|�rr()�exs rrUrU�s
��F�
�Hrc�0��eZdZ	dd��fd�
Z�fd�Z�xZS)�
_PoolCacheN��notifierc�2��||_t�|�|i|��yr)rlr<r!)r rlrrbr=s    �rr!z_PoolCache.__init__�s��� ��
�
���$�'�$�'rc�`��t�|�|�|s|jjd�yyr)r<�__delitem__rlrL)r �itemr=s  �rroz_PoolCache.__delitem__�s,���
���D�!���M�M���d�#�r)r%r&r'r!rorDrEs@rrjrj�s����+/�(�
$�
$rrjc��eZdZ	dZed��Z		d'd�Zeje	fd�Z
d�Zd�Zed	��Z
ed
��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��Zed��Z ed��Z!ed��Z"ed��Z#d�Z$d �Z%d!�Z&d"�Z'ed#��Z(ed$��Z)d%�Z*d&�Z+y)+rTc�&�|j|i|��Sr��Process)�ctxrrbs   rrtz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)Nrkrz&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_notifierrj�_cache�_maxtasksperchild�_initializer�	_initargs�os�	cpu_count�
ValueErrorrHrI�callable�	TypeError�
_processes�_repopulate_poolrT�exitcode�	terminater0�_get_sentinels�	threading�Threadr�_handle_workersrt�_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 �	processesrYrZ�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�rL)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�rPr�)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)rNr�)�workersrfs  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)NF�cleaning up worker %dT)�reversed�ranger�r�rrSr0)�pool�cleanedr`rfs    r�_join_exited_workerszPool._join_exited_workers!sg��	����%��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}rtr�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)Nrwrt�
PoolWorkerTzadded worker)
r�r�rf�name�replacer�r��appendrrS)rurtr�r�rWrXrYrZr�r\r`�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
�n�	tj|�rtj||||||||||	�
yyr)rr�r�)
rurtr�r�rWrXrYrZr�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�rG�sendr�rP�recvr�r#s rr~zPool._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�F�	|j|||�j�Sr)�apply_asyncrM)r rarrbs    r�applyz
Pool.applycs'��	�����d�D�1�5�5�7�7rc�P�	|j||t|�j�Sr)�
_map_asyncrrM�r ra�iterable�	chunksizes    rrzPool.mapjs'��	����t�X�w�	�B�F�F�H�Hrc�P�	|j||t|�j�Sr)r�rrMr�s    rrzPool.starmapqs'��	�
���t�X�{�I�F�J�J�L�Lrc�8�	|j||t|||�Sr)r�r�r rar�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)N���r)�	enumeraterTrU)r �
result_jobrar�r`�xrds       r�_guarded_task_generationzPool._guarded_task_generation�se����	�	J��A�!�(�+���1�!�1�d�Q�D�"�5�5�,���	J��q��s�$>���b�I�I��	J�s)�A�%�A�	A	�A�A�A	�	Ac���	|j�|dk(rOt|�}|jj|j	|j
||�|jf�|S|dkrtdj|���tj|||�}t|�}|jj|j	|j
t|�|jf�d�|D�S)NrzChunksize must be 1+, not {0:n}c3�.K�|]
}|D]}|����y�wrr(��.0�chunkrps   r�	<genexpr>zPool.imap.<locals>.<genexpr>������?�f�U���D��D�f���)r��IMapIteratorr�rLr��_job�_set_lengthr�rKr�
_get_tasksr�r rar�r�rc�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)NrzChunksize must be 1+, not {0!r}c3�.K�|]
}|D]}|����y�wrr(r�s   rr�z&Pool.imap_unordered.<locals>.<genexpr>�r�r�)r��IMapUnorderedIteratorr�rLr�r�r�r�rKrr�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�Nr)r��ApplyResultr�rLr�)r rarrbr�r�rcs       rr�zPool.apply_async�sQ��	�	
�����T�8�^�<�������v�{�{�A�t�T�4�@�A�4�H�I��
rc�8�	|j||t|||�Sr)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)N�__len__�rr�r�)
r�rNr�divmodr�r{rr��	MapResultr�rLr�r�)
r rar��mapperr�r�r��extrar�rcs
          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	�emptyrM)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�rrLrrS)r��cache�	taskqueuerurtr�r�rWrXrYrZr�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	�iterrMr|rrrSrT�_set�KeyErrorrLrR)
rrLrXr�r
r�taskseq�
set_lengthr^rdr_�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 sentinelrPz"ensuring that outqueue is not full�
z7result handler exiting: len(cache)=%s, thread._state=%s)r�r	rRrQrrSr|rrrr
rNr�rP�pollr�)rXrMr
rr^r_r`�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)ra�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)rrSr|rrr�r�rLr#s rrOz
Pool.close�sH���
�
�>�"��;�;�#���D�K�*/�D� � �'��!�!�%�%�d�+�rc�d�tjd�t|_|j	�y)Nzterminating pool)rrSr
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)rrSr|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)
rrS�_rlock�acquire�is_aliverPrr��time�sleep)rW�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�)rrSr
r|rLr+r�r'rJr�r	r0rNr�r��pid)r�rrWrXr�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'r��staticmethodrtr!�warnings�warnrr�rCr�r�r�r�r�r�r~r�r�rrr�r�r�r�r�r�r�r�classmethodr�r�r�r�r4rOr�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�rK�_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  rrMzApplyResult.get�s8���	�	�'���z�z�|����=�=��;�;���+�+�rc�^�|\|_|_|jr'|jr|j|j�|jr'|js|j|j�|jj�|j|j=d|_yr)	rGrLrArBr>�setr�r�r{�r r`rs   rrzApplyResult._setss��%(�"��
�t�{��>�>�d�m�m��N�N�4�;�;�'�����
�
�� � ����-��������K�K��	�	�"���
rr)
r%r&r'r!rErHr	rMrr:�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 r`�success_result�successrcs     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<yr�)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 rrpr[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)Nrrs)�dummyrt)rurrbrts    rrtzThreadPool.Process�s��"���%��%�%rNc�4�tj||||�yr)rr!)r r�rYrZs    rr!zThreadPool.__init__�s���
�
�d�I�{�H�=rc���tj�|_tj�|_|jj|_|jj|_yr)rr�r�r�rLr�rMr�r#s rr~zThreadPool._setup_queues�sD���)�)�+��
��*�*�,����-�-�+�+����.�.�,�,��rc�0�|jjgSr)r�rPr#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)rMr�Emptyr�rL)rWr*rr`s    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�r7rtr!r~r�r�r+rr(rrrr�sU���O��&��&�>�-�/���������r)Nr(NF))�__all__rarr�rr�r(r-rPr8r,rrr�
connectionr	r
rrr
�countr@rrrTrr*r3r8rfrU�dictrj�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

?>