ok

Mini Shell

Direktori : /opt/alt/python311/lib64/python3.11/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/multiprocessing/__pycache__/pool.cpython-311.opt-1.pyc

�

�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 �d!e!��Z&Gd"�d#e&��Z'Gd$�de"��Z(dS)&�Pool�
ThreadPool�N�)�util)�get_context�TimeoutError)�wait�INIT�RUN�CLOSE�	TERMINATEc�.�tt|���S�N)�list�map��argss �;/opt/alt/python311/lib64/python3.11/multiprocessing/pool.py�mapstarr/s����T�
����c�^�ttj|d|d����S)Nrr)r�	itertools�starmaprs r�starmapstarr2s%���	�!�$�q�'�4��7�3�3�4�4�4rc��eZdZd�Zd�ZdS)�RemoteTracebackc��||_dSr��tb)�selfrs  r�__init__zRemoteTraceback.__init__:s
������rc��|jSrr�r s r�__str__zRemoteTraceback.__str__<s	���w�rN)�__name__�
__module__�__qualname__r!r$�rrrr9s2�������������rrc��eZdZd�Zd�ZdS)�ExceptionWithTracebackc��tjt|��||��}d�|��}||_d|z|_dS)N�z

"""
%s""")�	traceback�format_exception�type�join�excr)r r1rs   rr!zExceptionWithTraceback.__init__@sB��
�
'��S�	�	�3��
;�
;��
�W�W�R�[�[����� �2�%����rc�,�t|j|jffSr)�rebuild_excr1rr#s r�
__reduce__z!ExceptionWithTraceback.__reduce__Es���T�X�t�w�/�/�/rN)r%r&r'r!r4r(rrr*r*?s2������&�&�&�
0�0�0�0�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��dSr)�reprr1�value�superr8r!)r r1r;�	__class__s   �rr!zMaybeEncodingError.__init__TsH�����9�9����%�[�[��
�
� �$�'�'�0�0���4�:�F�F�F�F�Frc�(�d|j�d|j�d�S)NzError sending result: 'z'. Reason: '�')r;r1r#s rr$zMaybeEncodingError.__str__Ys"���=A�Z�Z�Z�=A�X�X�X�G�	Grc�(�d|jj�d|�d�S)N�<z: �>)r=r%r#s r�__repr__zMaybeEncodingError.__repr__]s���!�^�4�4�4�d�d�d�;�;r)r%r&r'�__doc__r!r$rC�
__classcell__�r=s@rr8r8Psh�������'�'�G�G�G�G�G�
G�G�G�<�<�<�<�<�<�<rr8r(Fc��|�=t|t��r|dks"td�|�����|j}|j}t
|d��r2|j���|j	���|�||�d}|�
|�r%||k�r	|��}	n+#ttf$rtj
d��Yn�wxYw|	�tj
d��n�|	\}
}}}
}	d||
i|��f}n;#t$r.}|r|turt!||j��}d|f}Yd}~nd}~wwxYw	||
||f��nT#t$rG}t%||d��}tj
d	|z��||
|d|ff��Yd}~nd}~wwxYwdx}	x}
x}x}x}
}|dz
}|��|r||k��tj
d
|z��dS)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�J�K�K�K�
�,�C�
�+�C��w�	�"�"�!������������ � � �����X����I�
�
�x�
�I��,@�,@�	��3�5�5�D�D���'�"�	�	�	��J�B�C�C�C��E�	�����<��J�7�8�8�8��#'� ��Q��d�D�	 ��D�D�$�/�$�/�/�0�F�F���	 �	 �	 ��
?�$�.H�"H�"H�*�1�a�o�>�>���Q�Z�F�F�F�F�F�F�����	 ����	,��C��a�� �!�!�!�!���	,�	,�	,�(��F�1�I�6�6�G��J�I���
�
�
��C��a�%��)�*�+�+�+�+�+�+�+�+�����		,����48�7��7�s�7�V�7�d�7�T�D��Q��	�7�
�x�
�I��,@�,@�8	�J�.��:�;�;�;�;�;sB�&
B1�1%C�C�<
D�
D?�$D:�:D?�E�
F#�=F�F#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�H��||_t��j|i|��dSr)rmr<r!)r rmrrcr=s    �rr!z_PoolCache.__init__�s,��� ��
������$�'�$�'�'�'�'�'rc���t���|��|s|j�d��dSdSr)r<�__delitem__rmrM)r �itemr=s  �rrpz_PoolCache.__delitem__�sK���
�����D�!�!�!��	$��M���d�#�#�#�#�#�	$�	$r)r%r&r'rDr!rprErFs@rrkrk�sj���������+/�(�(�(�(�(�(�(�
$�
$�
$�
$�
$�
$�
$�
$�
$rrkc���eZdZdZdZed���Z		d)d�Zej	e
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,dS)-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|_|p
t��|_|���t
j��|_|j���|_	t|j	���|_||_||_
||_|�tj��pd}|dkrt#d���|�*t%|t&��r|dkrt#d���|�t)|��st+d���||_	|���nR#t0$rE|jD]}|j�|����|jD]}|�����wxYw|���}t;jt>j |j|j|j|j!|j|j|j"|j#|j
|j|j|j$||j	f���|_%d|j%_&tN|j%_|j%�(��t;jt>j)|j|j*|j#|j|jf���|_+d|j+_&tN|j+_|j+�(��t;jt>j,|j#|j-|jf���|_.d|j._&tN|j._|j.�(��t_j0||j1|j|j"|j#|j|j	|j%|j+|j.|jf	d	�
��|_2tN|_dS)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__�s_����
�����,�{�}�}��	��������+�-�-���!%�	� 5� 5� 7� 7��� �$�*?�@�@�@���!1���'���!���������+�!�I��q�=�=��E�F�F�F��'��.��4�4�
T�8H�A�8M�8M� �!R�S�S�S��"�8�K�+@�+@�"��<�=�=�=�#���	��!�!�#�#�#�#���	�	�	��Z�
"�
"���:�%��K�K�M�M�M���Z�
�
����������
	�����'�'�)�)�	�(�/��'��+�t���	�4�<��/�4�:�t�}�d�n��#�T�^�T�5K��&�	�4�3H�J� � � ���'+���#�&)���#���"�"�$�$�$�'�-��%��/�4�?�D�N��*�d�k�+������
%)���!�$'���!��� � �"�"�"�(�/��'��.�$�/�4�;�?� � � ���'+���#�&)���#���"�"�$�$�$��-��$�&��/�4�=�$�.�$�*��'��)=�t�?Q��&���5�����������s
�"D7�7AFc��|j|krC|d|��t|���t|dd���|j�d��dSdSdS)Nz&unclosed running multiprocessing pool )�sourcer�)r}�ResourceWarning�getattrr�rM)r �_warnrs   r�__del__zPool.__del__
sy���;�#����E�C�4�C�C�!�$�
0�
0�
0�
0��t�/��6�6�B��%�)�)�$�/�/�/�/�/�	��C�Brc
�p�|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__sY���n��0�C�N�0�0�S�%5�0�0���0�0� ���_�_�0�0�0�	1rc�B�|jjg}|jjg}g|�|�Sr)r�rQr�)r �task_queue_sentinels�self_notifier_sentinelss   rr�zPool._get_sentinelss1�� $�� 6�7��#'�#8�#@�"A��@�%�@�(?�@�@rc��d�|D��S)Nc�<�g|]}t|d���|j��S)�sentinel)rOr�)�.0rgs  r�
<listcomp>z.Pool._get_worker_sentinels.<locals>.<listcomp>s8��8�8�8�F�"�6�:�6�6�8���8�8�8rr(��workerss r�_get_worker_sentinelszPool._get_worker_sentinelss#��8�8��8�8�8�	8rc���d}ttt|������D]A}||}|j�0t	jd|z��|���d}||=�B|S)z�Cleanup after any worker processes which have exited due to reaching
        their specified lifetime.  Returns True if any workers were cleaned up.
        FN�cleaning up worker %dT)�reversed�ranger�r�rrTr0)�pool�cleanedrargs    r�_join_exited_workerszPool._join_exited_workers!st��
���%��D�	�	�*�*�+�+�	�	�A��!�W�F���*��
�2�Q�6�7�7�7����
�
�
�����G���rc��|�|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_pool1sN���+�+�D�I�t�|�,0�O�,0�J��
�,0�N�D�<M�,0�N�,0�,B�,0�,@�
B�B�	Brc
�D�t|t|��z
��D]}
||t||||||	f���}|j�dd��|_d|_|���|�|��tj	d����dS)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�9�,�-�-�
	'�
	'�A����F�%�x�)�&�(8�,�.�/�/�/�A�
�V�^�^�I�|�<�<�A�F��A�H�
�G�G�I�I�I��K�K��N�N�N��J�~�&�&�&�&�
	'�
	'rc
��t�|��r%t�||||||||||	�
�
dSdS)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�*�*�	9��(�(��g�y�$�)0�(�K�)1�3C�)7�
9�
9�
9�
9�
9�	9�	9rc���|j���|_|j���|_|jjj|_|jjj|_	dSr)
r~r�r�r�rH�sendr�rQ�recvr�r#s rrzPool._setup_queuesYsN���	�-�-�/�/��
���.�.�0�0����-�/�4����.�0�5����rc�D�|jtkrtd���dS)NzPool not running)r}rr�r#s r�_check_runningzPool._check_running_s&���;�#����/�0�0�0��rc�T�|�|||�����S)zT
        Equivalent of `func(*args, **kwds)`.
        Pool must be running.
        )�apply_asyncrN)r rbrrcs    r�applyz
Pool.applycs(��
����d�D�1�1�5�5�7�7�7rc�`�|�||t|�����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�B�F�F�H�H�Hrc�`�|�||t|�����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�F�J�J�L�L�Lrc�@�|�||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�9�	9rc#�K�	d}t|��D]\}}||||fifV��dS#t$r}||dzt|fifV�Yd}~dSd}~wwxYw)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�!�(�+�+�
6�
6���1�!�1�d�Q�D�"�5�5�5�5�5�
6�
6���	J�	J�	J��q��s�$>���b�I�I�I�I�I�I�I�I�I�I�����	J���s�!'�
A�A	�	Arc��|���|dkrLt|��}|j�|�|j||��|jf��|S|dkr"td�|�����t�
|||��}t|��}|j�|�|jt|��|jf��d�|D��S)zP
        Equivalent of `map()` -- can be MUCH slower than `Pool.map()`.
        rzChunksize must be 1+, not {0:n}c3�$K�|]}|D]}|V���dSrr(�r��chunkrqs   r�	<genexpr>zPool.imap.<locals>.<genexpr>��/����?�?�U��?�?��D�?�?�?�?�?�?�?r)r��IMapIteratorr�rMr��_job�_set_lengthr�rLr�
_get_tasksr�r rbr�r�rd�task_batchess      r�imapz	Pool.imap�s!��	
��������>�>�!�$�'�'�F��O����1�1�&�+�t�X�N�N��&��
�
�
�
�M��1�}�}� �5�<�<�!�#�#�$�$�$� �?�?�4��9�E�E�L�!�$�'�'�F��O����1�1�&�+�29�2>�@�@��&�	�
�
�
�@�?�f�?�?�?�?rc��|���|dkrLt|��}|j�|�|j||��|jf��|S|dkr"td�|�����t�
|||��}t|��}|j�|�|jt|��|jf��d�|D��S)zL
        Like `imap()` method but ordering of results is arbitrary.
        rzChunksize must be 1+, not {0!r}c3�$K�|]}|D]}|V���dSrr(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�0�F��O����1�1�&�+�t�X�N�N��&��
�
�
�
�M��1�}�}� �5�<�<�Y�G�G�I�I�I��?�?�4��9�E�E�L�*�4�0�0�F��O����1�1�&�+�29�2>�@�@��&�	�
�
�
�@�?�f�?�?�?�?rc��|���t|||��}|j�|jd|||fgdf��|S)z;
        Asynchronous version of `apply()` method.
        rN)r��ApplyResultr�rMr�)r rbrrcr�r�rds       rr�zPool.apply_async�sW��
	
�������T�8�^�<�<������v�{�A�t�T�4�@�A�4�H�I�I�I��
rc�@�|�||t|||��S)z9
        Asynchronous version of `map()` method.
        )r�rr�s      r�	map_asynczPool.map_async�s'��
���t�X�w�	�8����	rc��|���t|d��st|��}|�<tt	|��t	|j��dz��\}}|r|dz
}t	|��dkrd}t�|||��}t||t	|��||���}	|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�m�S���_�_�q�5H�I�I��I�u��
��Q��	��x�=�=�A����I����t�X�y�A�A���4��C��M�M�8�*8�:�:�:�������-�-�f�k�.4�.:�<�<��	
�	
�	
�	
��
rc��t||���|���s*|���|����(dSdS)N)�timeout)r	�emptyrN)r��change_notifierrs   r�_wait_for_updateszPool._wait_for_updates�se���Y��(�(�(�(�!�'�'�)�)�	"����!�!�!�"�'�'�)�)�	"�	"�	"�	"�	"rc��tj��}|jtks|r|jtkro|�|||||||	|
||�
�
g|�|���|
�}|�||��|jtk�]|r|jtk�o|�d��tj
d��dS)Nzworker handler exiting)r��current_threadr}rr
r�r�r	rMrrT)r��cache�	taskqueuervrur�r�rXrYrZr[r�r]r�r�thread�current_sentinelss                 rr�zPool._handle_workers�s���
�)�+�+���m�s�"�"�u�"���)�1K�1K����s�G�Y��g�'��h�/��
A�
A�
A�!O�#�";�";�D�"A�"A� N�I� N���!�!�"3�_�E�E�E��m�s�"�"�u�"���)�1K�1K�	�
�
�d�����
�+�,�,�,�,�,rc�J�tj��}t|jd��D]�\}}d}	|D]�}|jt
krt
jd��n�	||���5#t$rG}	|dd�\}
}	||
�	|d|	f��n#t$rYnwxYwYd}	~	��d}	~	wwxYw|r.t
jd��|r|dnd}||dz��	dx}x}}
��	dx}x}}
n#dx}x}}
wxYwt
jd��	t
jd��|�d��t
jd	��|D]
}|d���n$#t$rt
jd
��YnwxYwt
jd��dS)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)
r
rMrYr�rr�taskseq�
set_lengthr_rer`�idxr�s
             rr�zPool._handle_taskssB���)�+�+��#'�	�
�t�#<�#<�	4�	4��G�Z��D�
,�#���D��}��+�+��
�#L�M�M�M���!���D�	�	�	�	��$�!�!�!�#'����8���S�!�!�#�J�O�O�C�%���<�<�<�<��'�!�!�!� �D�!�������������	!����"�,��
�#7�8�8�8�)-�5�d�1�g�g�2��"�
�3��7�+�+�+��(,�+��+�w����'+�+��+�w�����t�+��+�w��+�+�+�+��J�2�3�3�3�
	J��J�H�I�I�I��L�L�����
�J�A�B�B�B��
�
����D�	�	�	�	�
���	J�	J�	J��J�H�I�I�I�I�I�	J����	
�
�)�*�*�*�*�*sl�*C=�A(�'C=�(
B9�2
B4�B�B4�
B,	�)B4�+B,	�,B4�/C=�4B9�93C=�=D�A
E+�+F�Fc��tj��}		|��}n,#ttf$rt	jd��YdSwxYw|jtkrt	jd��nR|�t	jd��n;|\}}}	||�||��n#t$rYnwxYwdx}x}}��|r�|jtkr�	|��}n,#ttf$rt	jd��YdSwxYw|�t	jd���a|\}}}	||�||��n#t$rYnwxYwdx}x}}|r|jtk��t|d��rdt	jd��	td��D]'}|j
���sn|���(n#ttf$rYnwxYwt	jd	t|��|j��dS)
Nrz.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�rrSrRrrTr}rrrr
rOr�rQ�pollr�)rYrNrrr_r`ra�objs        rr�zPool._handle_results=s����)�+�+��	$�
��s�u�u�����X�&�
�
�
��
�K�L�L�L����
�����}��#�#��
�I�J�J�J���|��
�8�9�9�9���K�C��C�
��c�
����3�'�'�'�'���
�
�
���
����#�#�D�#�3��+	$�.�	$��
��2�2�
��s�u�u�����X�&�
�
�
��
�K�L�L�L����
�����|��
�C�D�D�D���K�C��C�
��c�
����3�'�'�'�'���
�
�
���
����#�#�D�#�3���	$��
��2�2�"�8�Y�'�'�	��J�;�<�<�<�
��r�����A�#�+�0�0�2�2�����C�E�E�E�E����X�&�
�
�
���
����	
�
�L��%�j�j�&�-�	)�	)�	)�	)�	)sW�
!�%A
�	A
�B-�-
B:�9B:�
C"�"%D�
D�,E	�	
E�E�7G�G"�!G"c#�K�t|��}	ttj||����}|sdS||fV��-r)r�tupler�islice)rb�it�sizer�s    rr�zPool._get_tasksysO����
�"�X�X��	��i�&�r�4�0�0�1�1�A��
�����)�O�O�O�		rc� �td���)Nz:pool objects cannot be passed between processes or pickled)�NotImplementedErrorr#s rr4zPool.__reduce__�s��!�J���	rc��tjd��|jtkr9t|_t|j_|j�d��dSdS)Nzclosing pool)rrTr}rrr�r�rMr#s rrPz
Pool.close�sV���
�>�"�"�"��;�#����D�K�*/�D� �'��!�%�%�d�+�+�+�+�+��rc�n�tjd��t|_|���dS)Nzterminating pool)rrTr
r}r�r#s rr�zPool.terminate�s0���
�%�&�&�&�����������rc��tjd��|jtkrt	d���|jt
tfvrt	d���|j���|j	���|j
���|jD]}|����dS)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�5�
�[��	� 2�
2�
2��/�0�0�0���!�!�#�#�#�����!�!�!���!�!�#�#�#���	�	�A�
�F�F�H�H�H�H�	�	rc�z�tjd��|j���|���ru|j���r`|j���tj	d��|���r|j����ZdSdSdSdS)Nz7removing tasks from inqueue until task handler finishedr)
rrT�_rlock�acquire�is_aliverQrr��time�sleep)rX�task_handlerr s   r�_help_stuff_finishzPool._help_stuff_finish�s���	
�
�L�M�M�M����� � � ��#�#�%�%�	�'�/�*>�*>�*@�*@�	��O� � �"�"�"��J�q�M�M�M��#�#�%�%�	�'�/�*>�*>�*@�*@�	�	�	�	�	�	�	�	�	rc
���tjd��t|_|�d��t|_tjd��|�||t
|����|���s"t
|	��dkrtd���t|_|�d��|�d��tjd��tj
��|ur|���|rJt|dd��r4tjd��|D]}
|
j
�|
����tjd��tj
��|ur|���tjd	��tj
��|ur|���|rst|dd��r_tjd
��|D]J}
|
���r0tjd|
jz��|
����GdSdSdS)Nzfinalizing poolz&helping task handler/workers to finishrz.Cannot have cache with result_hander not alivezjoining worker handlerr�zterminating workerszjoining task handlerzjoining result handlerzjoining pool workersr�)rrTr
r}rMr-r�r)rKr�rr0rOr�r��pid)r�r
rXrYr�r�worker_handlerr,�result_handlerrr�s           rr�zPool._terminate_pool�sb��	
�
�$�%�%�%�
!*������D�!�!�!�'����
�;�<�<�<����w��c�$�i�i�@�@�@��'�'�)�)�	B��E�
�
�a��� �@�B�B�
B�!*������D�!�!�!����T����	
�
�+�,�,�,��#�%�%�^�;�;����!�!�!��	"�G�D��G�[�1�1�	"��J�,�-�-�-��
"�
"���:�%��K�K�M�M�M���
�)�*�*�*��#�%�%�\�9�9��������
�+�,�,�,��#�%�%�^�;�;����!�!�!��	�G�D��G�[�1�1�	��J�-�.�.�.��
�
���:�:�<�<���J�6���>�?�?�?��F�F�H�H�H��
	�	�	�	�
�
rc�.�|���|Sr)r�r#s r�	__enter__zPool.__enter__�s���������rc�.�|���dSr)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�r3r8r(rrrr�sa���������O��*�*��\�*�CE�04�O�O�O�O�f%�M�s�0�0�0�0�1�1�1�A�A�A�
�8�8��\�8��
�
��\�
�B�B�B��'�'��\�'�$�	9�	9��\�	9�6�6�6�1�1�1� "��8�8�8�8�I�I�I�I�M�M�M�M�FJ��9�9�9�9�	J�	J�	J�@�@�@�@�:@�@�@�@�8&(�b�4������BF������KO������:�"�"�"��\�"�
�-�-��[�-�(�++�++��\�++�Z�9)�9)��\�9)�v����\�����
,�,�,����

�
�
�����\���3�3��[�3�j�������rc�V�eZdZd�Zd�Zd�Zdd�Zdd�Zd�Ze	e
j��ZdS)	r�c���||_tj��|_t	t
��|_|j|_||_||_	||j|j<dSr)
r|r��Event�_event�next�job_counterr�r��	_callback�_error_callback)r r�r�r�s    rr!zApplyResult.__init__�sS����
��o�'�'�����%�%��	��k���!���-���!%���D�I���rc�4�|j���Sr)r@�is_setr#s r�readyzApplyResult.ready�s���{�!�!�#�#�#rc�|�|���s"td�|�����|jS)Nz{0!r} not ready)rGr�rL�_successr#s r�
successfulzApplyResult.successful�s7���z�z�|�|�	=��.�5�5�d�;�;�<�<�<��}�rNc�:�|j�|��dSr)r@r	�r rs  rr	zApplyResult.wait�s�������!�!�!�!�!rc��|�|��|���st�|jr|jS|j�r)r	rGrrI�_valuerLs  rrNzApplyResult.get�sD���	�	�'�����z�z�|�|�	����=�	��;���+�rc��|\|_|_|jr!|jr|�|j��|jr!|js|�|j��|j���|j|j=d|_dSr)	rIrNrCrDr@�setr�r�r|�r rars   rrzApplyResult._sets���%(�"��
�t�{��>�	(�d�m�	(��N�N�4�;�'�'�'���	.��
�	.�� � ���-�-�-���������K��	�"���
�
�
rr)
r%r&r'r!rGrJr	rNrr<�types�GenericAlias�__class_getitem__r(rrr�r��s�������&�&�&�$�$�$����
"�"�"�"��������$��E�$6�7�7���rr�c��eZdZd�Zd�ZdS)rc��t�||||���d|_dg|z|_||_|dkr/d|_|j���|j|j	=dS||zt||z��z|_dS)NrTr)r�r!rIrN�
_chunksize�_number_leftr@rPr�r��bool)r r�r��lengthr�r�s      rr!zMapResult.__init__s������T�4��,:�	�	<�	<�	<���
��f�v�o���#�����>�>� !�D���K�O�O������D�I�&�&�&� &�	� 1�D��)�9K�4L�4L� L�D���rc��|xjdzc_|\}}|r�|jr|||j||jz|dz|jz�<|jdkrP|jr|�|j��|j|j=|j���d|_	dSdS|s|jrd|_||_|jdkrP|j
r|�
|j��|j|j=|j���d|_	dSdS)NrrF)rXrIrNrWrCr�r�r@rPr|rD)r ra�success_result�successrds     rrzMapResult._set)s1�����Q����(�����	"�t�}�	"�CI�D�K��$�/�)�1�Q�3���*?�?�@�� �A�%�%��>�0��N�N�4�;�/�/�/��K��	�*�����!�!�!�!��
�
�
�&�%��
%�t�}�
%� %��
�$���� �A�%�%��'�6��(�(���5�5�5��K��	�*�����!�!�!�!��
�
�
�
&�%rN)r%r&r'r!rr(rrrrs5������M�M�M�"�"�"�"�"rrc�2�eZdZd�Zd�Zdd�ZeZd�Zd�ZdS)r�c�*�||_tjtj����|_tt��|_|j|_tj
��|_d|_d|_
i|_||j|j<dS)Nr)r|r��	Condition�Lock�_condrArBr�r��collections�deque�_items�_index�_length�	_unsorted)r r�s  rr!zIMapIterator.__init__Gst����
��(���)9�)9�:�:��
���%�%��	��k���!�'�)�)������������!%���D�I���rc��|Srr(r#s r�__iter__zIMapIterator.__iter__Rs���rNc��|j5	|j���}n�#t$r�|j|jkrd|_td�|j�|��	|j���}n5#t$r(|j|jkrd|_td�td�wxYwYnwxYwddd��n#1swxYwY|\}}|r|S|�r)
rbre�popleft�
IndexErrorrfrgr|�
StopIterationr	r)r rrqr]r;s     rrAzIMapIterator.nextUsE��
�Z�	1�	1�

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

1����	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1� �����	��L��sJ�C	�$�C	�AB:�(B�B:�2B4�4B:�7C	�9B:�:C	�	C
�C
c�
�|j5|j|kr�|j�|��|xjdz
c_|j|jvrW|j�|j��}|j�|��|xjdz
c_|j|jv�W|j���n
||j|<|j|jkr|j|j	=d|_
ddd��dS#1swxYwYdS�Nr)rbrfrer�rh�pop�notifyrgr�r�r|rQs   rrzIMapIterator._setmsE��
�Z�	"�	"��{�a�����"�"�3�'�'�'����q� ����k�T�^�3�3��.�,�,�T�[�9�9�C��K�&�&�s�+�+�+��K�K�1�$�K�K��k�T�^�3�3��
�!�!�#�#�#�#�$'���q�!��{�d�l�*�*��K��	�*�!��
�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"s�C#C8�8C<�?C<c���|j5||_|j|jkr-|j���|j|j=d|_ddd��dS#1swxYwYdSr)rbrgrfrrr�r�r|)r rZs  rr�zIMapIterator._set_length~s���
�Z�	"�	"�!�D�L��{�d�l�*�*��
�!�!�#�#�#��K��	�*�!��
�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"s�AA�A�!Ar)	r%r&r'r!rjrA�__next__rr�r(rrr�r�Esk������	&�	&�	&��������,�H�"�"�"�""�"�"�"�"rr�c��eZdZd�ZdS)r�c��|j5|j�|��|xjdz
c_|j���|j|jkr|j|j=d|_ddd��dS#1swxYwYdSrp)	rbrer�rfrrrgr�r�r|rQs   rrzIMapUnorderedIterator._set�s���
�Z�	"�	"��K���s�#�#�#��K�K�1��K�K��J�������{�d�l�*�*��K��	�*�!��
�
	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"s�A(A=�=B�BN)r%r&r'rr(rrr�r��s#������"�"�"�"�"rr�c�n�eZdZdZed���Zdd�Zd�Zd�Zed���Z	ed	���Z
d
�ZdS)rFc��ddlm}||i|��S)Nrrt)�dummyru)rvrrcrus    rruzThreadPool.Process�s)��"�"�"�"�"�"��w��%��%�%�%rNr(c�@�t�||||��dSr)rr!)r r�rZr[s    rr!zThreadPool.__init__�s ���
�
�d�I�{�H�=�=�=�=�=rc��tj��|_tj��|_|jj|_|jj|_dSr)r�r�r�r�rMr�rNr�r#s rrzThreadPool._setup_queues�s>���)�+�+��
��*�,�,����-�+����.�,����rc��|jjgSr)r�rQr#s rr�zThreadPool._get_sentinels�s���%�-�.�.rc��gSrr(r�s rr�z ThreadPool._get_worker_sentinels�s���	rc��		|�d����#tj$rYnwxYwt|��D]}|�d���dS)NTF)�block)rNr��Emptyr�rM)rXr,r ras    rr-zThreadPool._help_stuff_finish�s{��	�
)����%��(�(�(�
)���{�	�	�	��D�	�����t���	�	�A��K�K������	�	s��,�,c�.�tj|��dSr)r*r+)r r�rrs    rr	zThreadPool._wait_for_updates�s���
�7�����r)NNr()r%r&r'r�r9rur!rr�r�r-r	r(rrrr�s��������O��&�&��\�&�>�>�>�>�-�-�-�/�/�/�����\������\������r)Nr(NF))�__all__rcrr�r�r�r*r-rRr:r,rrr�
connectionr	r
rrr
�countrBrrrUrr*r3r8rgrV�dictrk�objectrr��AsyncResultrr�r�rr(rr�<module>r�s����<�
 ����������	�	�	�	�������������������������������'�'�'�'�'�'�'�'��������������	��i�o�������5�5�5������i����0�0�0�0�0�0�0�0����<�<�<�<�<��<�<�<�"GK��+<�+<�+<�+<�Z
�
�
�$�$�$�$�$��$�$�$�.v�v�v�v�v�6�v�v�v�x)8�)8�)8�)8�)8�&�)8�)8�)8�V��%"�%"�%"�%"�%"��%"�%"�%"�V?"�?"�?"�?"�?"�6�?"�?"�?"�J	"�	"�	"�	"�	"�L�	"�	"�	"�$�$�$�$�$��$�$�$�$�$r

Zerion Mini Shell 1.0