diff options
author | NewUserHa <32261870+NewUserHa@users.noreply.github.com> | 2024-01-27 08:29:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-27 08:29:38 (GMT) |
commit | 547c135d70760f974ed0476a32a6809e708bfe4d (patch) | |
tree | 1e643dc9cfde7865ca4e887eda3d7446321ebd18 /Lib/concurrent/futures | |
parent | 926881dc10ebf77069e02e66eea3e0d3ba500fe5 (diff) | |
download | cpython-547c135d70760f974ed0476a32a6809e708bfe4d.zip cpython-547c135d70760f974ed0476a32a6809e708bfe4d.tar.gz cpython-547c135d70760f974ed0476a32a6809e708bfe4d.tar.bz2 |
Simplify concurrent.futures.process code by using itertools.batched() (GH-114221)
Diffstat (limited to 'Lib/concurrent/futures')
-rw-r--r-- | Lib/concurrent/futures/process.py | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index ffaffdb..ca843e1 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -190,16 +190,6 @@ class _SafeQueue(Queue): super()._on_queue_feeder_error(e, obj) -def _get_chunks(*iterables, chunksize): - """ Iterates over zip()ed iterables in chunks. """ - it = zip(*iterables) - while True: - chunk = tuple(itertools.islice(it, chunksize)) - if not chunk: - return - yield chunk - - def _process_chunk(fn, chunk): """ Processes a chunk of an iterable passed to map. @@ -847,7 +837,7 @@ class ProcessPoolExecutor(_base.Executor): raise ValueError("chunksize must be >= 1.") results = super().map(partial(_process_chunk, fn), - _get_chunks(*iterables, chunksize=chunksize), + itertools.batched(zip(*iterables), chunksize), timeout=timeout) return _chain_from_iterable_of_lists(results) |