[issue28699] Imap from ThreadPool behaves unexpectedly
Xiang Zhang
report at bugs.python.org
Mon Nov 28 03:22:21 EST 2016
Xiang Zhang added the comment:
> 4. Guard against misbehaving generators/iterables *before* they are put into the taskqueue.
This approach is good. 2 points about the patch:
1. How about _map_async(map)? Does it need the same strategy? For an iterator with __len__ defined it seems to get the same issue as here.
from multiprocessing import Pool
def double(x):
return 2 * x
class buggy:
def __iter__(self):
return self
def __next__(self):
raise Exception('oops')
def __len__(self):
return 1
list(Pool(processes=2).map(double, buggy()))
list(Pool(processes=2).map(double, buggy())) # hangs
2. The logic in _handle_tasks to handle task, i to could be removed I think. With _guarded_task_generation the for loop cannot fail and the logic itself is buggy now.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28699>
_______________________________________
More information about the Python-bugs-list
mailing list