K izdZddlmZddlmZddlmZddlmZ ddl m Z dd giZ d d gZ edd Zd ZdZdZy)z, Thin wrappers around `concurrent.futures`. )contextmanager) length_hint) cpu_count)tqdm) TqdmWarningz github.com/ casperdcl thread_map process_mapc#Kt|dd}|xs|j}t|||}|j||||`y|j|yw)z>get (create if necessary) and then restore `tqdm_class`'s lock_lockN)getattrget_lockset_lockr ) tqdm_class lock_nameold_locklocks ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tqdm/contrib/concurrent.py ensure_lockrsdz7D1H  ,z**,D 4D )D J  H%sAAc  |j}d|vrt|d|d<|jdt}|jdt dt dz}|jdd}|jd d }t || 5} |||j| f 5} t|| j|g|d|ifi|cd d d cd d d S#1swYnxYw d d d y #1swYy xYw)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  chunksizer)r)r initializerinitargsN) copyrpop tqdm_autominrrrlistmap) PoolExecutorfn iterables tqdm_kwargskwargsrrrrlkexs r _executor_mapr.s   Ff%il3wL)4J**]CIK!O,DEK ;*I ;+I Z9 5[ kz?R?R$&5* [-/ 6266"#Ny#NI#NYRXYZ [ [[[ [ [ [[[[s$C:+&C$ C:$C- )C::Dc.ddlm}t||g|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.futuresr0r.)r(r)r*r0s rr r 6s6 +R K) K{ KKcddlm}|r:d|vr6ttt|}|dkDrddlm}|d|ztdd |vr|j}d |d <t||g|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)ProcessPoolExecutorri)warnzIterable length %d > 1000 but `chunksize` is not set. This may seriously degrade multiprocess performance. Set `chunksize=1` or more.r) stacklevelrmp_lock) r1r4maxr&rwarningsr5rr!r.)r(r)r*r4longest_iterable_lenr5s rr r Hs&7[ 3 #3{I#>? $ & % /1EF ,+%!&&( #, K ,b L9 L LLr2N)r)__doc__ contextlibroperatorrosrautorr#stdr __author____all__rr.r r r2rrDsW& $k] +  ' & &[2L$!Mr2