MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / _Gate

Class _Gate

scripts/test-impact/profile_map_v2.py:140–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138
139
140class _Gate:
141 __slots__ = ("cancel", "context", "work", "callback_error")
142
143 def __init__(self, cancel, context):
144 self.cancel = cancel
145 self.context = context
146 self.work = 0
147 self.callback_error = None
148
149 def poll(self):
150 self.work = 0
151 if self.cancel is None:
152 return
153 try:
154 answer = self.cancel(self.context)
155 except BaseException as error:
156 # Identity distinguishes a callback's parser-shaped exception from
157 # a parser failure; neither its class nor message is sufficient.
158 self.callback_error = error
159 raise
160 if type(answer) is not bool:
161 raise ProfileMapInvalidArgumentError("cancel must return bool")
162 if answer:
163 raise ProfileMapCancelledError("profile map build cancelled")
164
165 def step(self):
166 self.work += 1
167 if self.work == _POLL_INTERVAL:
168 self.poll()
169
170 def parser_cancel(self, _context):
171 self.poll()
172 return False
173
174
175def _bounded_add(current, amount, cap, label):

Callers 1

build_profile_map_v2Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected