MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / _Spinner

Class _Spinner

openkb/agent/compiler.py:337–361  ·  view source on GitHub ↗

Animated dots spinner that runs in a background thread.

Source from the content-addressed store, hash-verified

335
336
337class _Spinner:
338 """Animated dots spinner that runs in a background thread."""
339
340 def __init__(self, label: str):
341 self._label = label
342 self._stop = threading.Event()
343 self._thread: threading.Thread | None = None
344
345 def start(self) -> None:
346 sys.stdout.write(f" {self._label}")
347 sys.stdout.flush()
348 self._thread = threading.Thread(target=self._run, daemon=True)
349 self._thread.start()
350
351 def _run(self) -> None:
352 while not self._stop.wait(timeout=1.0):
353 sys.stdout.write(".")
354 sys.stdout.flush()
355
356 def stop(self, suffix: str = "") -> None:
357 self._stop.set()
358 if self._thread:
359 self._thread.join()
360 sys.stdout.write(f" {suffix}\n")
361 sys.stdout.flush()
362
363
364def _format_usage(elapsed: float, usage) -> str:

Callers 1

_llm_callFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected