File: //usr/lib/python3.9/site-packages/pip/_internal/utils/__pycache__/parallel.cpython-39.pyc
a
?�fL
� @ s$ d Z ddgZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZ dd lmZ er�dd
lmZmZmZmZmZ ddlmZ eejejf Zed�Zed
�ZzddlZW n ey� dZY n0 dZdZedd� �Zddd�Zddd�Z ddd�Z!e�se�re Z"Z#ne Z"e!Z#dS )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_multiprocess�map_multithread� )�contextmanager)�Pool)�DEFAULT_POOLSIZE)�PY2��map)�MYPY_CHECK_RUNNING)�Callable�Iterable�Iterator�Union�TypeVar��pool�S�TNTFi�� c c sB z"| V W | � � | �� | �� n| � � | �� | �� 0 dS )z>Return a context manager making sure the pool closes properly.N)�close�joinZ terminater � r �@/usr/lib/python3.9/site-packages/pip/_internal/utils/parallel.py�closing4 s
�r � c C s
t | |�S )z�Make 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 )�func�iterable� chunksizer r r �
_map_fallbackB s r c C s<