Skip to content

Reject a pre_dispatch below one - #1839

Merged
Nanored4498 merged 7 commits into
joblib:mainfrom
RavSinghChandan:reject-non-positive-pre-dispatch
Sep 15, 2026
Merged

Nanored4498 merged 7 commits into
joblib:mainfrom
RavSinghChandan:reject-non-positive-pre-dispatch

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

Parallel(n_jobs=2, pre_dispatch=0) returns an empty list:

>>> Parallel(n_jobs=2, pre_dispatch=0)(delayed(abs)(-1) for _ in range(4))
[]

The amount is fed straight into islice, so nothing is ever dispatched and the caller gets no results and no error for work they asked to run. A negative value surfaces an islice error about sys.maxsize instead, which says nothing about the argument that was passed.

batch_size next to it already refuses a non-positive value, so this follows the same shape and reports the expression as it was passed (so '0*n_jobs' is echoed rather than the 0 it evaluated to).

Reverting the change fails the four new tests

Parallel(n_jobs=2, pre_dispatch=0) returned an empty list: the amount is fed
straight into islice, so nothing was ever dispatched and the caller got no
results and no error for work they asked to run. A negative value surfaced an
islice error about sys.maxsize instead.

batch_size next to it already refuses a non-positive value, so this follows
the same shape and reports the expression as it was passed.
@codecov

codecov Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.12%. Comparing base (df03f5d) to head (60619e6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1839      +/-   ##
==========================================
- Coverage   94.15%   94.12%   -0.04%     
==========================================
  Files          46       46              
  Lines        8145     8152       +7     
==========================================
+ Hits         7669     7673       +4     
- Misses        476      479       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Nanored4498 Nanored4498 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR. Just a few comments. Then I think it could be merged.

Comment thread joblib/test/test_parallel.py Resolved
Comment thread joblib/test/test_parallel.py Resolved
Comment thread joblib/parallel.py Resolved
@Nanored4498

Nanored4498 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the modifications. Could you add a brief note in the CHANGES.rst?

@Nanored4498
Nanored4498 merged commit 02170e3 into joblib:main Sep 15, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants