Xiang Zhang added the comment:
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
----------
nosy: +xiang.zhang
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28699>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com