Repository navigation
Reject nonpositive chunksizes in pool imap methods - #481
Open
JackyHsu-X wants to merge 1 commit into
Open
JackyHsu-X wants to merge 1 commit into
JackyHsu-X wants to merge 1 commit into
Conversation
Signed-off-by: JackyHsu-X <xv1070733106@gmail.com>
auvipy
self-requested a review
October 24, 2026 04:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Reject non-positive
chunksizewithValueErrorinPool.imap()andPool.imap_unordered(), before consuming the iterable or queuing tasks. This replaces assertions that disappear underpython -O.With the current code,
list(pool.imap(abs, [-1, -2], chunksize=0))returns[]underpython -O;imap_unordered()does the same. The nonempty input is silently discarded. The explicit checks keep validation active in optimized Python, matching the standard library's behavior.Adds regressions for zero and negative chunk sizes, empty and nonempty iterables, unchanged cache/queue state on rejection, and valid chunk sizes after rejection. Includes a changelog entry.
Verification
-O.t/unitrun: 97 passed, 51 skipped, 2 failed. A pristine checkout at3a806fbhas the same two failures (test_exception_info_log_before_pickleandtest_exception_info_log_after_pickle), with 85 passed and 51 skipped.-O. Both methods reject 0/-1 and subsequently execute valid batches with chunk sizes 1/2 on the fix, with and without-O.The complete Windows pool suite was not completed: a real spawn-pool check stalled and was stopped. Other Windows unit tests have two failures also reproduced on the pristine checkout. No cross-version or free-threaded matrix was run.
No existing issue is claimed as fixed. Open PRs #473 and #475 address timeout and worker-exit handling, respectively.
Codex assisted with investigation, implementation, test execution, and this PR description.