
    LMh                         d Z ddlmZ ddlmZ ddlmZ ddlmZ	 ddl
mZ dd	giZd
dgZedd            Zd Zd Zd ZdS )z,
Thin wrappers around `concurrent.futures`.
    )contextmanager)length_hint)	cpu_count   )tqdm)TqdmWarningzgithub.com/	casperdcl
thread_mapprocess_map c              #      K   t          | dd          }|p|                                 }t          |||          }|                     |           |V  || `dS |                     |           dS )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       W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/tqdm/contrib/concurrent.pyensure_lockr      s       z7D11H,z**,,D4D))D
JJJH%%%%%    c                 j   |                                 }d|vrt          |d                   |d<   |                    dt                    }|                    dt	          dt                      dz                       }|                    dd          }|                    d	d
          }t          ||          5 }	 | ||j        |	f          5 }
t           | |
j	        |g|R d|ifi |          cddd           cddd           S # 1 swxY w Y   	 ddd           dS # 1 swxY w Y   d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].
    totalr   r   max_workers       	chunksize   r   r   )r   )r   initializerinitargsN)
copyr   pop	tqdm_autominr   r   r   listmap)PoolExecutorfn	iterablestqdm_kwargskwargsr   r   r   r   lkexs              r   _executor_mapr/      s    Ff%il33wL)44J**]CIKK!O,D,DEEK

;**I

;++I	Z9	5	5	5 [\kz?R$&5* * * 	[-/

626"#Ny#N#N#NI#N#NYYRXYYZZ	[ 	[ 	[ 	[ 	[ 	[ 	[[ [ [ [ [ [ [ [	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [s6   <D(%D6D(D	D(D	D((D,/D,c                 0    ddl m} t          || g|R i |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.futuresr1   r/   )r)   r*   r+   r1   s       r   r
   r
   6   s7     655555+RK)KKK{KKKr   c                     ddl m} |rHd|vrDt          t          t          |                    }|dk    rddlm}  |d|z  t          d           d	|vr|                                }d
|d	<   t          || g|R i |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   )ProcessPoolExecutorr   i  )warnzIterable length %d > 1000 but `chunksize` is not set. This may seriously degrade multiprocess performance. Set `chunksize=1` or more.r   )
stacklevelr   mp_lock)
r2   r4   maxr'   r   warningsr5   r   r"   r/   )r)   r*   r+   r4   longest_iterable_lenr5   s         r   r   r   H   s    & 766666 	,[33  #3{I#>#>??$&&%%%%%%D /1EF , , , , +%%!&&((#,K ,bL9LLLLLLr   N)r   )__doc__
contextlibr   operatorr   osr   autor   r$   stdr   
__author____all__r   r/   r
   r    r   r   <module>rD      s     & % % % % %                   $ $ $ $ $ $      k]+

' 
& 
& 
& 
&[ [ [2L L L$!M !M !M !M !Mr   