Same as map, but catches exceptions and return them instead. Parameters ---------- fn : function The function to be invoked. iterator : Iterator Input iterator. Returns ------- out_iter : Iterator[MapResult]
(self, fn, iterator)
| 464 | return self._threadpool.submit(worker, fn, args, kwargs) |
| 465 | |
| 466 | def map_with_error_catching(self, fn, iterator): |
| 467 | """Same as map, but catches exceptions and return them instead. |
| 468 | |
| 469 | Parameters |
| 470 | ---------- |
| 471 | fn : function |
| 472 | The function to be invoked. |
| 473 | |
| 474 | iterator : Iterator |
| 475 | Input iterator. |
| 476 | |
| 477 | Returns |
| 478 | ------- |
| 479 | out_iter : Iterator[MapResult] |
| 480 | The result iterator. |
| 481 | """ |
| 482 | worker = lambda x: self._worker_run_with_error_catching(fn, (x,), None) |
| 483 | return self._threadpool.map(worker, iterator) |