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

Function wait_projects_with_stats

tests/windows/mcp_stdio.py:153–181  ·  view source on GitHub ↗

Poll list_projects until a project row carries node/edge counts. index_repository returns when the pipeline finishes, but the project stats are published asynchronously; on slow CI runners the first list_projects can observe the registration row before its counts land (`nodes` absen

(server, timeout=90.0, poll=1.0)

Source from the content-addressed store, hash-verified

151
152
153def wait_projects_with_stats(server, timeout=90.0, poll=1.0):
154 """Poll list_projects until a project row carries node/edge counts.
155
156 index_repository returns when the pipeline finishes, but the project
157 stats are published asynchronously; on slow CI runners the first
158 list_projects can observe the registration row before its counts land
159 (`nodes` absent/None). That window is environmental, not a product
160 regression (#1952), so wait it out instead of failing setup on it.
161
162 Returns (projects, last_text): the parsed project list (possibly [])
163 and the last raw list_projects payload for diagnostics.
164 """
165 deadline = time.time() + timeout
166 last_txt = ""
167 while True:
168 resp = server.call_tool("list_projects", {}, timeout=60)
169 txt, err = server.tool_text(resp)
170 projects = []
171 if not err and txt:
172 last_txt = txt
173 try:
174 projects = json.loads(txt).get("projects") or []
175 except ValueError:
176 projects = []
177 if projects and projects[0].get("nodes") is not None:
178 return projects, last_txt
179 if time.time() >= deadline:
180 return projects, last_txt
181 time.sleep(poll)

Callers 1

index_and_countFunction · 0.90

Calls 3

call_toolMethod · 0.80
tool_textMethod · 0.80
getMethod · 0.65

Tested by 1

index_and_countFunction · 0.72