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 <rep...@bugs.python.org> <http://bugs.python.org/issue28699> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com