MCPcopy Index your code
hub / github.com/python/cpython / _AllCompletedWaiter

Class _AllCompletedWaiter

Lib/concurrent/futures/_base.py:105–133  ·  view source on GitHub ↗

Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED).

Source from the content-addressed store, hash-verified

103 self.event.set()
104
105class _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
135class _AcquireFutures(object):
136 """A context manager that does an ordered acquire of Future conditions."""

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…