This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xiang.zhang
Recipients davin, elias, lev-veshnyakov, xiang.zhang
Date 2016-11-17.08:51:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1479372669.8.0.227918498467.issue28699@psf.upfronthosting.co.za>
In-reply-to
Content
Hi Davin, could it be fixed like this?

diff -r 05a728e1da15 Lib/multiprocessing/pool.py
--- a/Lib/multiprocessing/pool.py	Wed Nov 16 16:35:53 2016 -0800
+++ b/Lib/multiprocessing/pool.py	Thu Nov 17 16:35:38 2016 +0800
@@ -398,7 +398,7 @@
             except Exception as ex:
                 job, ind = task[:2] if task else (0, 0)
                 if job in cache:
-                    cache[job]._set(ind + 1, (False, ex))
+                    cache[job]._set(ind + 1 if task else 0, (False, ex))
                 if set_length:
                     util.debug('doing set_length()')
                     set_length(i+1)

It seems to me the bug is _handle_tasks doesn't treat the exception correctly if it's on the very first. Every time it _set(ind + 1) since if there is any exception the task is the previous task and + 1 is needed. But if the exception occurs at the very first, task is None and the + 1 is not needed.

I am not very sure but the reported cases work correctly now:

list(Pool(processes=2).imap(double, get_numbers()))  # raises error now
list(pool.imap(str, gen()))  # raises error now
History
Date User Action Args
2016-11-17 08:51:09xiang.zhangsetrecipients: + xiang.zhang, elias, davin, lev-veshnyakov
2016-11-17 08:51:09xiang.zhangsetmessageid: <1479372669.8.0.227918498467.issue28699@psf.upfronthosting.co.za>
2016-11-17 08:51:09xiang.zhanglinkissue28699 messages
2016-11-17 08:51:09xiang.zhangcreate