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