꺐 d Z ddgZddlmZ ddlmZ ddlmZ ddlmZ ddl mZmZm Z mZmZ ddlmZ eej ej f Z ed Z ed Z ddlZdZn # e$ r d ZY nw xY wdZedede e fd Z ddeegef dee dede e fdZ ddeegef dee dede e fdZ ddeegef dee dede e fdZerexZZdS eZeZdS )ab Convenient parallelization of higher order functions. This module provides two helper functions, with appropriate fallbacks on Python 2 and on systems lacking support for synchronization mechanisms: - map_multiprocess - map_multithread These helpers work like Python 3's map, with two differences: - They don't guarantee the order of processing of the elements of the iterable. - The underlying process/thread pools chop the iterable into a number of chunks, so that for very long iterables using a large value for chunksize can make the job complete much faster than using the default value of 1. map_multiprocessmap_multithread )contextmanager)Poolpool)CallableIterableIteratorTypeVarUnion)DEFAULT_POOLSIZESTNFTi r returnc # K | V | j | j | j dS # | j | j | j w xY w)z>Return a context manager making sure the pool closes properly.N)closejoin terminater s /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el9.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/utils/parallel.pyclosingr . sy s 7 /A& funciterable chunksizec " t | | S )zMake an iterator applying func to each element in iterable. This function is the sequential fallback either on Python 2 where Pool.imap* doesn't react to KeyboardInterrupt or when sem_open is unavailable. )map)r r r s r _map_fallbackr ; s tX c t t 5 } |j | || cddd S # 1 swxY w Y dS )zChop iterable into chunks and submit them to a process pool. For very long iterables using a large value for chunksize can make the job complete much faster than using the default value of 1. Return an unordered iterator of the results. N)r ProcessPoolimap_unorderedr r r r s r _map_multiprocessr$ G s >4"t"49==> > > > > > > > > > > > > > > > > >s ;??c t t t 5 } |j | || cddd S # 1 swxY w Y dS )zChop iterable into chunks and submit them to a thread pool. For very long iterables using a large value for chunksize can make the job complete much faster than using the default value of 1. Return an unordered iterator of the results. N)r ThreadPoolr r" r# s r _map_multithreadr' U s ,-- . . >$"t"49==> > > > > > > > > > > > > > > > > >s AAA)r )__doc____all__ contextlibr multiprocessingr r! r multiprocessing.dummyr&