Skip to content

fix: exit earily on empty list in map and parallel#324

Merged
yaythomas merged 1 commit intomainfrom
empty-iterable-map
Mar 9, 2026
Merged

fix: exit earily on empty list in map and parallel#324
yaythomas merged 1 commit intomainfrom
empty-iterable-map

Conversation

@yaythomas
Copy link
Contributor

Description of changes:

Fix crash when calling context.map() or context.parallel() with empty list. Previously, empty executables caused ThreadPoolExecutor to be initialized with max_workers=0, raising ValueError.

Add early return in ConcurrentExecutor.execute() to immediately return empty BatchResult when no items need processing. This avoids creating ThreadPoolExecutor with invalid worker count and matches expected behavior where empty input produces empty output.

Add regression test to verify empty list handling works correctly.

Issue #, if available:
closes #323

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Fix crash when calling context.map() or context.parallel() with empty
list. Previously, empty executables caused ThreadPoolExecutor to be
initialized with max_workers=0, raising ValueError.

Add early return in ConcurrentExecutor.execute() to immediately return
empty BatchResult when no items need processing. This avoids creating
ThreadPoolExecutor with invalid worker count and matches expected
behavior where empty input produces empty output.

Add regression test to verify empty list handling works correctly.

closes #323
@yaythomas yaythomas merged commit c16cd40 into main Mar 9, 2026
16 checks passed
@yaythomas yaythomas deleted the empty-iterable-map branch March 9, 2026 23:50
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.

[Bug]: Map on empty list breaks durable execution

3 participants