mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-19 23:34:24 +01:00
gatelock 0.15.1 error_report, installed by the CLI as app diet-guard-gate: uncaught, thread and Tk callback errors plus a gate loop frozen over 1 s go to the app-errors spool. The stall watch arms in run(), after the turn wait, so building the gate is no stall. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""Error and slow-wait reporting for the diet gate (utils DOCS-app-errors.md).
|
|
|
|
``install`` runs once from the CLI entry point: uncaught, thread and Tk
|
|
callback errors, and a Tk loop frozen over 1 s, go to the app-errors spool,
|
|
from which the PC's ingest files a board ticket. Only the CLI installs it, so
|
|
tests that build a gate window never touch the real spool. The Flutter app
|
|
reports separately, as ``diet-guard``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import TYPE_CHECKING
|
|
|
|
from gatelock import error_report
|
|
from gatelock.error_report import watch_stalls
|
|
|
|
if TYPE_CHECKING:
|
|
import tkinter as tk
|
|
|
|
APP = "diet-guard-gate"
|
|
REPO = "kuhyx/diet-guard"
|
|
|
|
|
|
@dataclass
|
|
class _Slot:
|
|
"""Holds the process's reporter once installed."""
|
|
|
|
reporter: error_report.Reporter | None = None
|
|
|
|
|
|
#: The installed reporter (``SLOT.reporter``); None until ``install``.
|
|
SLOT = _Slot()
|
|
|
|
|
|
def install() -> error_report.Reporter:
|
|
"""Hook this process's errors once; return the reporter."""
|
|
SLOT.reporter = error_report.install(APP, REPO)
|
|
return SLOT.reporter
|
|
|
|
|
|
def watch(root: tk.Misc) -> None:
|
|
"""Report ``root``'s freezes over 1 s, once ``install`` has run."""
|
|
if SLOT.reporter is not None:
|
|
watch_stalls(root, SLOT.reporter)
|