a Re| @ s\ d Z ddgZddlmZ ddlmZ ddlmZ ddlmZ ddl mZmZm Z mZmZ ddlmZ eejej f Zed Zed ZzddlZW n ey dZY n0 d ZdZeee e dddZdeegef ee ee e dddZdeegef ee ee e dddZdeegef ee ee e dddZerPe ZZneZeZdS )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_POOLSIZESTNTFi )r returnc c sB z"| V W | | | n| | | 0 dS )z>Return a context manager making sure the pool closes properly.N)closejoin terminater r /builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/utils/parallel.pyclosing. s r )funciterable chunksizer c C s 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 r r r _map_fallback; s r c C s<