(self, fn, itr, done_callback, unpack_args)
| 608 | |
| 609 | #c def _imap_child(self, fn, itr, done_callback, bint unpack_args): |
| 610 | def _imap_child(self, fn, itr, done_callback, unpack_args): #p |
| 611 | #c cdef bint append_done |
| 612 | self._busy_lock_inc() |
| 613 | _done_append = self._done.append |
| 614 | _failed_append = self._failed.append |
| 615 | if done_callback is False: |
| 616 | for args in itr: |
| 617 | if self._shutdown_children: |
| 618 | break |
| 619 | try: |
| 620 | if unpack_args: |
| 621 | for _ in fn(*args): |
| 622 | pass |
| 623 | else: |
| 624 | for _ in fn(args): |
| 625 | pass |
| 626 | except Exception as exc: |
| 627 | self._append_failed(0, exc, args, {}) |
| 628 | elif done_callback is True: |
| 629 | for args in itr: |
| 630 | if self._shutdown_children: |
| 631 | break |
| 632 | try: |
| 633 | if unpack_args: |
| 634 | for result in fn(*args): |
| 635 | _done_append(result) |
| 636 | self._done_cnt_inc() |
| 637 | else: |
| 638 | for result in fn(args): |
| 639 | _done_append(result) |
| 640 | self._done_cnt_inc() |
| 641 | except Exception as exc: |
| 642 | self._append_failed(0, exc, args, {}) |
| 643 | elif callable(done_callback): |
| 644 | for args in itr: |
| 645 | if self._shutdown_children: |
| 646 | break |
| 647 | try: |
| 648 | if unpack_args: |
| 649 | for result in fn(*args): |
| 650 | done_callback(result) |
| 651 | else: |
| 652 | for result in fn(args): |
| 653 | done_callback(result) |
| 654 | except Exception as exc: |
| 655 | self._append_failed(0, exc, args, {}) |
| 656 | self._cleanup_child() |
| 657 | |
| 658 | def map(self, fn, itr, done_callback=True, direct=True, unpack_args=True): |
| 659 | """ Quickly process a bunch of work items. |
nothing calls this directly
no test coverage detected