feat: indie status page MVP -- FastAPI + SQLite
- 8 DB models (services, incidents, monitors, subscribers, etc.) - Full CRUD API for services, incidents, monitors - Public status page with live data - Incident detail page with timeline - API key authentication - Uptime monitoring scheduler - 13 tests passing - TECHNICAL_DESIGN.md with full spec
This commit is contained in:
commit
902133edd3
4655 changed files with 1342691 additions and 0 deletions
48
venv/lib/python3.11/site-packages/mypy/gclogger.py
Normal file
48
venv/lib/python3.11/site-packages/mypy/gclogger.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import gc
|
||||
import time
|
||||
from collections.abc import Mapping
|
||||
|
||||
|
||||
class GcLogger:
|
||||
"""Context manager to log GC stats and overall time."""
|
||||
|
||||
def __enter__(self) -> GcLogger:
|
||||
self.gc_start_time: float | None = None
|
||||
self.gc_time = 0.0
|
||||
self.gc_calls = 0
|
||||
self.gc_collected = 0
|
||||
self.gc_uncollectable = 0
|
||||
gc.callbacks.append(self.gc_callback)
|
||||
self.start_time = time.time()
|
||||
return self
|
||||
|
||||
def gc_callback(self, phase: str, info: Mapping[str, int]) -> None:
|
||||
if phase == "start":
|
||||
assert self.gc_start_time is None, "Start phase out of sequence"
|
||||
self.gc_start_time = time.time()
|
||||
elif phase == "stop":
|
||||
assert self.gc_start_time is not None, "Stop phase out of sequence"
|
||||
self.gc_calls += 1
|
||||
self.gc_time += time.time() - self.gc_start_time
|
||||
self.gc_start_time = None
|
||||
self.gc_collected += info["collected"]
|
||||
self.gc_uncollectable += info["uncollectable"]
|
||||
else:
|
||||
assert False, f"Unrecognized gc phase ({phase!r})"
|
||||
|
||||
def __exit__(self, *args: object) -> None:
|
||||
while self.gc_callback in gc.callbacks:
|
||||
gc.callbacks.remove(self.gc_callback)
|
||||
|
||||
def get_stats(self) -> Mapping[str, float]:
|
||||
end_time = time.time()
|
||||
result = {
|
||||
"gc_time": self.gc_time,
|
||||
"gc_calls": self.gc_calls,
|
||||
"gc_collected": self.gc_collected,
|
||||
"gc_uncollectable": self.gc_uncollectable,
|
||||
"build_time": end_time - self.start_time,
|
||||
}
|
||||
return result
|
||||
Loading…
Add table
Add a link
Reference in a new issue