MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / evict_if_needed

Method evict_if_needed

examples/server/server.py:10503–10518  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

10501 self.evict_if_needed()
10502
10503 def evict_if_needed(self) -> None:
10504 if self.max_bytes <= 0:
10505 return
10506 entries = [path for path in self.path.glob("*.safetensors") if path.is_file()]
10507 total = sum(path.stat().st_size for path in entries)
10508 if total <= self.max_bytes:
10509 return
10510 for path in sorted(entries, key=lambda item: item.stat().st_mtime_ns):
10511 if total <= self.max_bytes:
10512 break
10513 try:
10514 size = path.stat().st_size
10515 path.unlink()
10516 total -= size
10517 except OSError:
10518 continue
10519
10520
10521@dataclass

Callers 1

saveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected