[New-bugs-announce] [issue28699] Imap from ThreadPool behaves unexpectedly

Lev Veshnyakov report at bugs.python.org
Tue Nov 15 13:22:19 EST 2016


New submission from Lev Veshnyakov:

Consider the following code:

from multiprocessing.pool import ThreadPool

pool = ThreadPool(10)

def gen():
    yield 1 + '1' # here is an error

print(list(pool.imap(str, gen()))) # prints []
print(list(pool.map(str, gen()))) # raises TypeError

The difference is, that the line with imap prints an empty list, while the line with map raises an exception, as expected.

Change the above snippet of code, adding additional yield statement:

from multiprocessing.pool import ThreadPool

pool = ThreadPool(10)

def gen():
    yield 1
    yield 1 + '1' # here is an error

print(list(pool.imap(str, gen()))) # raises TypeError
print(list(pool.map(str, gen()))) # also would raise TypeError

So now both map and imap will raise the exception, as expected. Therefore I suppose the behavior of imap showed in the first case is wrong.

----------
components: Library (Lib)
messages: 280872
nosy: lev-veshnyakov
priority: normal
severity: normal
status: open
title: Imap from ThreadPool behaves unexpectedly
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28699>
_______________________________________


More information about the New-bugs-announce mailing list