Message280872
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. |
|
Date |
User |
Action |
Args |
2016-11-15 18:22:19 | lev-veshnyakov | set | recipients:
+ lev-veshnyakov |
2016-11-15 18:22:19 | lev-veshnyakov | set | messageid: <1479234139.82.0.483433491582.issue28699@psf.upfronthosting.co.za> |
2016-11-15 18:22:19 | lev-veshnyakov | link | issue28699 messages |
2016-11-15 18:22:19 | lev-veshnyakov | create | |
|