Private
Public Access
TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 10: refactor(gui_2): migrate L1152 _gui_func entry log to Result[T] (Phase 10 site 6)
Extracted _gui_func_entry_log_result(app) -> Result[None] helper above the App._gui_func method. ANTI-SLIMING: full Result[T] propagation (NO except+pass-after-log). The helper returns Result(data=None) on success or Result(data=None, errors=[ErrorInfo]) on exception (logging NOT a drain per the user's principle 2026-06-17). The legacy _gui_func method preserves its signature, calls the helper, drains errors to self._last_request_errors, and proceeds with the rest of the render loop. Tests: 2 new tests verify both paths (success and OSError). Audit: L1152 reclassified from INTERNAL_SILENT_SWALLOW (8 sites remaining, was 9). New helper L1152 is INTERNAL_COMPLIANT.
This commit is contained in:
+29
-6
@@ -1165,12 +1165,35 @@ def _shutdown_save_ini_result(app: "App") -> Result[None]:
|
||||
# the cost of the first full-UI render. Splitting them attributes the gap.
|
||||
if not getattr(self, "_gui_func_entered", False):
|
||||
self._gui_func_entered = True
|
||||
try:
|
||||
init_ts = getattr(self.controller, "_init_start_ts", None)
|
||||
if init_ts is not None:
|
||||
sys.stderr.write(f"[startup] first _gui_func entry at {(time.time() - init_ts) * 1000:.1f}ms after init (window/GL + font/style/post_init callbacks done)\n")
|
||||
sys.stderr.flush()
|
||||
except Exception: pass
|
||||
log_result = _gui_func_entry_log_result(self)
|
||||
if not log_result.ok:
|
||||
if not hasattr(self, '_last_request_errors'): self._last_request_errors = []
|
||||
self._last_request_errors.append(("_gui_func.entry_log", log_result.errors[0]))
|
||||
|
||||
def _gui_func_entry_log_result(app: "App") -> Result[None]:
|
||||
"""Drain-aware variant of App._gui_func startup-timing log (L1152 INTERNAL_SILENT_SWALLOW).
|
||||
|
||||
Extracts the first-frame startup-timing sys.stderr.write/flush from
|
||||
App._gui_func into a Result-returning helper. On exception (broken pipe,
|
||||
OSError on the stderr stream), converts to ErrorInfo (logging NOT a drain
|
||||
per the user's principle 2026-06-17). The legacy _gui_func method
|
||||
drains to self._last_request_errors.
|
||||
|
||||
[C: src/gui_2.py:App._gui_func (L1152 legacy wrapper)]
|
||||
"""
|
||||
try:
|
||||
init_ts = getattr(app.controller, "_init_start_ts", None)
|
||||
if init_ts is not None:
|
||||
sys.stderr.write(f"[startup] first _gui_func entry at {(time.time() - init_ts) * 1000:.1f}ms after init (window/GL + font/style/post_init callbacks done)\n")
|
||||
sys.stderr.flush()
|
||||
return Result(data=None)
|
||||
except Exception as e:
|
||||
return Result(data=None, errors=[ErrorInfo(
|
||||
kind=ErrorKind.INTERNAL,
|
||||
message=f"gui_func entry log failed: {e}",
|
||||
source="gui_2._gui_func_entry_log_result",
|
||||
original=e,
|
||||
)])
|
||||
|
||||
# One-shot: kick off the controller's heavy-module warmup on the shared
|
||||
# io_pool once the FIRST frame has actually been painted. Waiting one frame
|
||||
|
||||
Reference in New Issue
Block a user