Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED).
| 103 | self.event.set() |
| 104 | |
| 105 | class _AllCompletedWaiter(_Waiter): |
| 106 | """Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED).""" |
| 107 | |
| 108 | def __init__(self, num_pending_calls, stop_on_exception): |
| 109 | self.num_pending_calls = num_pending_calls |
| 110 | self.stop_on_exception = stop_on_exception |
| 111 | self.lock = threading.Lock() |
| 112 | super().__init__() |
| 113 | |
| 114 | def _decrement_pending_calls(self): |
| 115 | with self.lock: |
| 116 | self.num_pending_calls -= 1 |
| 117 | if not self.num_pending_calls: |
| 118 | self.event.set() |
| 119 | |
| 120 | def add_result(self, future): |
| 121 | super().add_result(future) |
| 122 | self._decrement_pending_calls() |
| 123 | |
| 124 | def add_exception(self, future): |
| 125 | super().add_exception(future) |
| 126 | if self.stop_on_exception: |
| 127 | self.event.set() |
| 128 | else: |
| 129 | self._decrement_pending_calls() |
| 130 | |
| 131 | def add_cancelled(self, future): |
| 132 | super().add_cancelled(future) |
| 133 | self._decrement_pending_calls() |
| 134 | |
| 135 | class _AcquireFutures(object): |
| 136 | """A context manager that does an ordered acquire of Future conditions.""" |
no outgoing calls
no test coverage detected
searching dependent graphs…