MCPcopy Index your code
hub / github.com/RustPython/RustPython / _AllCompletedWaiter

Class _AllCompletedWaiter

Lib/concurrent/futures/_base.py:111–139  ·  view source on GitHub ↗

Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED).

Source from the content-addressed store, hash-verified

109 self.event.set()
110
111class _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
141class _AcquireFutures(object):
142 """A context manager that does an ordered acquire of Future conditions."""

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected