Skip to content

Commit b1af9c3

Browse files
authored
🐛 Respect n_workers in max_chunks_per_worker (#31)
1 parent cd77bd8 commit b1af9c3

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/mapply/mapply.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ def _choose_n_chunks(
2929
"""Choose final amount of chunks to be sent to the ProcessPool."""
3030
# no sense running parallel if data is too small
3131
n_chunks = int(shape[axis] / chunk_size)
32+
if n_workers < 1:
33+
n_workers = N_CORES
3234

3335
if max_chunks_per_worker:
3436
# no sense making too many chunks
35-
n_chunks = min(n_chunks, max_chunks_per_worker * N_CORES)
37+
n_chunks = min(n_chunks, max_chunks_per_worker * n_workers)
3638
if n_chunks < 1 or n_workers == 1 or N_CORES == 1:
3739
# no sense running parallel
3840
n_chunks = 1

0 commit comments

Comments
 (0)