Helper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled.
| 737 | |
| 738 | |
| 739 | class _GatheringFuture(futures.Future): |
| 740 | """Helper for gather(). |
| 741 | |
| 742 | This overrides cancel() to cancel all the children and act more |
| 743 | like Task.cancel(), which doesn't immediately mark itself as |
| 744 | cancelled. |
| 745 | """ |
| 746 | |
| 747 | def __init__(self, children, *, loop): |
| 748 | assert loop is not None |
| 749 | super().__init__(loop=loop) |
| 750 | self._children = children |
| 751 | self._cancel_requested = False |
| 752 | |
| 753 | def cancel(self, msg=None): |
| 754 | if self.done(): |
| 755 | return False |
| 756 | ret = False |
| 757 | for child in self._children: |
| 758 | if child.cancel(msg=msg): |
| 759 | ret = True |
| 760 | if ret: |
| 761 | # If any child tasks were actually cancelled, we should |
| 762 | # propagate the cancellation request regardless of |
| 763 | # *return_exceptions* argument. See issue 32684. |
| 764 | self._cancel_requested = True |
| 765 | return ret |
| 766 | |
| 767 | |
| 768 | def gather(*coros_or_futures, return_exceptions=False): |
no outgoing calls
no test coverage detected
searching dependent graphs…