In multiprocessing, if you give a pool.map a zero-length iterator and specify a nonzero chunksize, the process hangs indefinitely. Example: import multiprocessing pool = multiprocessing.Pool() pool.map(len, [], chunksize=1) # hang forever Attached simple testcase and simple fix. I observed this behavior on 2.6 and 3.1, but only verified the patch on 3.1. Unless the line numbers changed it will probably fix it on 2.6 as well.
I'm not familiar with multiprocessing but I gave a quick look at the patch. If the 'iterable' is an iterator/generator "if len(iterable) == 0:" may fail since these objects don't usually have a __len__. More tests for this situation are probably needed too.
Can anyone review this patch? It is a very simple fix to catch this one edge case. As this can cause multiprocessing to enter a state where it needs to be externally killed, it would be good if this made 2.6.3.