New submission from Elias Zamaria:

I have the following code:

from multiprocessing import Pool

def double(x):
    return 2 * x

def get_numbers():
    raise Exception("oops")
    yield 1
    yield 2

print(list(Pool(processes=2).imap(double, get_numbers())))


I would expect it to raise an exception, but instead it just prints "[]", 
seeming to indicate that imap ran fine and produced no values.

This seems similar to the behavior described in bugs 23051 and 26333, but this 
happens if the iterator directly raises an exception before yielding anything. 
If I move the raise statement below one or both of the yields, I get an 
exception from imap as expected.

I am experiencing this with Python 3.5.2 on OS X 10.11.6. I haven't tried it 
with any other versions.

----------
components: Library (Lib)
messages: 280146
nosy: elias
priority: normal
severity: normal
status: open
title: multiprocessing.Pool.imap swallows exceptions thrown by generators
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28625>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to