(fut)
| 762 | return outer |
| 763 | |
| 764 | def _done_callback(fut): |
| 765 | nonlocal nfinished |
| 766 | nfinished += 1 |
| 767 | |
| 768 | if outer is None or outer.done(): |
| 769 | if not fut.cancelled(): |
| 770 | # Mark exception retrieved. |
| 771 | fut.exception() |
| 772 | return |
| 773 | |
| 774 | if not return_exceptions: |
| 775 | if fut.cancelled(): |
| 776 | # Check if 'fut' is cancelled first, as |
| 777 | # 'fut.exception()' will *raise* a CancelledError |
| 778 | # instead of returning it. |
| 779 | exc = fut._make_cancelled_error() |
| 780 | outer.set_exception(exc) |
| 781 | return |
| 782 | else: |
| 783 | exc = fut.exception() |
| 784 | if exc is not None: |
| 785 | outer.set_exception(exc) |
| 786 | return |
| 787 | |
| 788 | if nfinished == nfuts: |
| 789 | # All futures are done; create a list of results |
| 790 | # and set it to the 'outer' future. |
| 791 | results = [] |
| 792 | |
| 793 | for fut in children: |
| 794 | if fut.cancelled(): |
| 795 | # Check if 'fut' is cancelled first, as 'fut.exception()' |
| 796 | # will *raise* a CancelledError instead of returning it. |
| 797 | # Also, since we're adding the exception return value |
| 798 | # to 'results' instead of raising it, don't bother |
| 799 | # setting __context__. This also lets us preserve |
| 800 | # calling '_make_cancelled_error()' at most once. |
| 801 | res = exceptions.CancelledError( |
| 802 | '' if fut._cancel_message is None else |
| 803 | fut._cancel_message) |
| 804 | else: |
| 805 | res = fut.exception() |
| 806 | if res is None: |
| 807 | res = fut.result() |
| 808 | results.append(res) |
| 809 | |
| 810 | if outer._cancel_requested: |
| 811 | # If gather is being cancelled we must propagate the |
| 812 | # cancellation regardless of *return_exceptions* argument. |
| 813 | # See issue 32684. |
| 814 | exc = fut._make_cancelled_error() |
| 815 | outer.set_exception(exc) |
| 816 | else: |
| 817 | outer.set_result(results) |
| 818 | |
| 819 | arg_to_fut = {} |
| 820 | children = [] |
nothing calls this directly
no test coverage detected