� L�g����dZddlmZddlmZddlmZddlmZ ddl m Z dd giZ d d gZ edd ���Zd�Zd�Zd�ZdS)z, Thin wrappers around `concurrent.futures`. �)�contextmanager)� length_hint)� cpu_count�)�tqdm)� TqdmWarningz github.com/� casperdcl� thread_map� process_map�c#��K�t|dd��}|p|���}t|||��}|�|��|V�|�|`dS|�|��dS)z>get (create if necessary) and then restore `tqdm_class`'s lock�_lockN)�getattr�get_lock�set_lockr)� tqdm_class� lock_name�old_lock�locks �g/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/tqdm/contrib/concurrent.py� ensure_lockrs������z�7�D�1�1�H� � ,�z�*�*�,�,�D� �4��D� )� )�D�������� �J�J�J��� � � � ����H�%�%�%�%�%�c �j�|���}d|vrt|d��|d<|�dt��}|�dt dt ��dz����}|�dd��}|�d d ��}t ||� ��5} |||j| f� ��5} t|| j |g|�Rd|i�fi|����cd d d ��cd d d ��S#1swxYwY d d d ��d S#1swxYwYd S)a Implementation of `thread_map` and `process_map`. Parameters ---------- tqdm_class : [default: tqdm.auto.tqdm]. max_workers : [default: min(32, cpu_count() + 4)]. chunksize : [default: 1]. lock_name : [default: "":str]. �totalrr� max_workers� �� chunksize�rr )r)r� initializer�initargsN) �copyr�pop� tqdm_auto�minrrr�list�map) � PoolExecutor�fn� iterables� tqdm_kwargs�kwargsrrrr�lk�exs r� _executor_mapr/s��� � � � �F��f���%�i��l�3�3��w�����L�)�4�4�J��*�*�]�C��I�K�K�!�O�,D�,D�E�E�K�� � �;��*�*�I�� � �;��+�+�I� �Z�9� 5� 5� 5�[�� �\�k�z�?R�$&�5�*�*�*� [�-/�� � �6�2�6�"�#N�y�#N�#N�#N�I�#N�#N�Y�Y�RX�Y�Y�Z�Z� [� [� [� [� [� [� [�[�[�[�[�[�[�[�[� [� [� [� [���� [� [� [� [� [�[�[�[�[�[�[�[�[�[�[�[�[����[�[�[�[�[�[s6�<D(�%D�6 D(�D �D(�D �D(�(D,�/D,c�0�ddlm}t||g|�Ri|��S)a� Equivalent of `list(map(fn, *iterables))` driven by `concurrent.futures.ThreadPoolExecutor`. Parameters ---------- tqdm_class : optional `tqdm` class to use for bars [default: tqdm.auto.tqdm]. max_workers : int, optional Maximum number of workers to spawn; passed to `concurrent.futures.ThreadPoolExecutor.__init__`. [default: max(32, cpu_count() + 4)]. r)�ThreadPoolExecutor)�concurrent.futuresr1r/)r)r*r+r1s rr r 6s7��6�5�5�5�5�5� �+�R� K�)� K� K� K�{� K� K�Krc���ddlm}|rHd|vrDttt|����}|dkrddlm}|d|ztd���d |vr|���}d |d <t||g|�Ri|��S) a� Equivalent of `list(map(fn, *iterables))` driven by `concurrent.futures.ProcessPoolExecutor`. Parameters ---------- tqdm_class : optional `tqdm` class to use for bars [default: tqdm.auto.tqdm]. max_workers : int, optional Maximum number of workers to spawn; passed to `concurrent.futures.ProcessPoolExecutor.__init__`. [default: min(32, cpu_count() + 4)]. chunksize : int, optional Size of chunks sent to worker processes; passed to `concurrent.futures.ProcessPoolExecutor.map`. [default: 1]. lock_name : str, optional Member of `tqdm_class.get_lock()` to use [default: mp_lock]. r)�ProcessPoolExecutorri�)�warnz�Iterable length %d > 1000 but `chunksize` is not set. This may seriously degrade multiprocess performance. Set `chunksize=1` or more.r)� stacklevelr�mp_lock) r2r4�maxr'r�warningsr5rr"r/)r)r*r+r4�longest_iterable_lenr5s rr r Hs���&7�6�6�6�6�6�� ,�[� �3�3� #�3�{�I�#>�#>�?�?�� �$� &� &� %� %� %� %� %� %� �D�/�1E�F��� ,� ,� ,� ,��+�%�%�!�&�&�(�(� �#,� �K� � �,�b� L�9� L� L� L� � L� L�LrN)r )�__doc__� contextlibr�operatorr�osr�autorr$�stdr� __author__�__all__rr/r r �rr�<module>rDs�����&�%�%�%�%�%� � � � � � �������$�$�$�$�$�$��������k�]� +� � �� '��� &� &� &��� &�[�[�[�2L�L�L�$!M�!M�!M�!M�!Mr
Memory