Skip to content

Keep zero-worker map calls serial and honor return_exceptions - #962

Open
justavibedev wants to merge 2 commits into
AnswerDotAI:mainfrom
justavibedev:fix/serial-executor-map
Open

justavibedev wants to merge 2 commits into
AnswerDotAI:mainfrom
justavibedev:fix/serial-executor-map

Conversation

@justavibedev

Copy link
Copy Markdown

Switching a batch to serial execution for debugging can change what happens to failed items. For example, parallel(int, ['1', 'bad', '2'], n_workers=0, return_exceptions=True) raises on the second item. With workers, the result includes the exception and processing continues. The first commit uses the existing exception handler in the serial path for both executor types.

I also hit a separate problem when reusing a ProcessPoolExecutor(0). The first call to map ran locally. The second tried to pickle my lambda because the first call had changed the stored worker count to 1. The second commit keeps the configured worker count across calls.

I reproduced both failures on main, added notebook tests for each, and ran the full parallel notebook with nbdev-test nbs/03a_parallel.ipynb --n-workers 0. It passed locally on Python 3.12. Codex assisted with the patch and tests.

This branch has not been deployed

No deployments
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.

1 participant