U ja @sdZddgZddlmZddlmZddlmZddlmZ ddl m Z m Z m Z mZmZddlmZeejej fZed Zed Zz dd lZWnek rd ZYnXd ZdZeddZdddZdddZdddZereZZneZeZd S)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)Poolpool)CallableIterableIteratorTypeVarUnion)DEFAULT_POOLSIZESTNTFiccs*z |VW5|||XdS)z>Return a context manager making sure the pool closes properly.N)closejoin terminaterrt/private/var/folders/k6/_7fsz4ts3b78x3b3xwrxjh_c8s8xv7/T/pip-unpacked-wheel-bug3gbve/pip/_internal/utils/parallel.pyclosing.s  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. )map)funciterable chunksizerrr _map_fallback<src Cs0tt}||||W5QRSQRXdS)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_unorderedrrrrrrr_map_multiprocessGs rc Cs2ttt}||||W5QRSQRXdS)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 rrrrr_map_multithreadTs r!)r)r)r)__doc____all__ contextlibrmultiprocessingrrrZmultiprocessing.dummyr typingrr r r r Zpip._vendor.requests.adaptersr rrZmultiprocessing.synchronize ImportErrorZ LACK_SEM_OPENTIMEOUTrrrr!rrrrrrs2