ReL @sdZddgZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZerdd lmZmZmZmZmZdd lmZeejejfZed Zed ZyddlZWnek rdZYnXdZdZeddZdddZdddZ dddZ!espe r}eZ"Z#n e Z"e!Z#dS)abConvenient 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)Pool)DEFAULT_POOLSIZE)PY2)map)MYPY_CHECK_RUNNING)CallableIterableIteratorUnionTypeVar)poolSTNTFic cs/z |VWd|j|j|jXdS)z>Return a context manager making sure the pool closes properly.N)closejoin terminate)rr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/parallel.pyclosing4s    rcCs 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. )r)funciterable chunksizerrr _map_fallbackBsrc Cs0tt}|j|||SWdQRXdS)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_unordered)rrrrrrr_map_multiprocessMs rc Cs3ttt}|j|||SWdQRXdS)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 ThreadPoolrr)rrrrrrr_map_multithreadZs r!)$__doc____all__ contextlibrmultiprocessingrrZmultiprocessing.dummyr Zpip._vendor.requests.adaptersrZpip._vendor.sixrpip._vendor.six.movesrpip._internal.utils.typingr typingr r r r rrrrZmultiprocessing.synchronize ImportErrorZ LACK_SEM_OPENTIMEOUTrrrr!rrrrrrs8 (