Message281029
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 |
|
Date |
User |
Action |
Args |
2016-11-17 08:51:09 | xiang.zhang | set | recipients:
+ xiang.zhang, elias, davin, lev-veshnyakov |
2016-11-17 08:51:09 | xiang.zhang | set | messageid: <1479372669.8.0.227918498467.issue28699@psf.upfronthosting.co.za> |
2016-11-17 08:51:09 | xiang.zhang | link | issue28699 messages |
2016-11-17 08:51:09 | xiang.zhang | create | |
|