MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / wait_for_indexing

Method wait_for_indexing

benches/memory_usage.py:327–366  ·  view source on GitHub ↗

Block until PHPantom finishes indexing. PHPantom sends ``$/progress`` with ``kind: "end"`` when indexing finishes. We also accept a quiet period as a fallback for workspaces where indexing is trivial and no progress tokens are emitted.

(self, timeout: float = INDEX_TIMEOUT)

Source from the content-addressed store, hash-verified

325 return self.wait_for_response(rid, timeout=timeout)
326
327 def wait_for_indexing(self, timeout: float = INDEX_TIMEOUT) -> None:
328 """Block until PHPantom finishes indexing.
329
330 PHPantom sends ``$/progress`` with ``kind: "end"`` when indexing
331 finishes. We also accept a quiet period as a fallback for
332 workspaces where indexing is trivial and no progress tokens are
333 emitted.
334 """
335 deadline = time.monotonic() + timeout
336 active_tokens: set[str] = set()
337 saw_any_progress = False
338
339 while time.monotonic() < deadline:
340 remaining = deadline - time.monotonic()
341 if remaining <= 0:
342 break
343 try:
344 msg = self._notifications.get(timeout=min(remaining, 2.0))
345 except queue.Empty:
346 # Silence. If we never saw progress, treat it as "done"
347 # (trivial workspace). If all tokens ended, also done.
348 if not saw_any_progress or not active_tokens:
349 return
350 continue
351
352 method = msg.get("method", "")
353
354 if method == "$/progress":
355 saw_any_progress = True
356 token = str(msg["params"].get("token", ""))
357 value = msg["params"].get("value", {})
358 kind = value.get("kind", "")
359 if kind == "begin":
360 active_tokens.add(token)
361 elif kind == "end":
362 active_tokens.discard(token)
363 if not active_tokens:
364 return
365
366 raise TimeoutError(f"Indexing did not finish within {timeout}s")
367
368 def drain_notifications(self, seconds: float) -> None:
369 """Read and discard notifications for *seconds*."""

Callers 2

run_hello_worldFunction · 0.95
run_laravel_modelFunction · 0.95

Calls 2

getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected