From https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor.map
If a func call raises an exception, then that exception will be raised when its value is retrieved from the iterator.
The following snippet only outputs the first exception (Exception: 1), and stops. Does this contradict the above statement? I expect the following to print out all exceptions in the loop.
def test_func(val):
raise Exception(val)
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
for r in executor.map(test_func,[1,2,3,4,5]):
try:
print r
except Exception as exc:
print 'generated an exception: %s' % (exc)