From 121216096cc83e44fcded4324e1358338decdea7 Mon Sep 17 00:00:00 2001 From: Ahmed Allam Date: Sun, 4 Oct 2026 05:24:10 +0000 Subject: [PATCH] fix(telemetry): route every unraisable and thread exception to strix.log, never stderr Replaces the pattern-matched urllib3/http.client filter with a generic rule: sys.unraisablehook (finalizers, __del__, GC and weakref callbacks, files closed at exit) and threading.excepthook are replaced for the life of the process with hooks that log the report at WARNING on strix.telemetry. That goes to strix.log, and to stderr only when the stream handler runs at DEBUG (STRIX_DEBUG=1). Nothing is delegated to Python's default printers; a report arriving after the strix handlers are torn down is dropped instead of reaching logging.lastResort, and failures inside logging itself are swallowed so nothing can print mid-shutdown. tests/test_hook_exceptions_logged.py covers both hooks in-process and end to end in a fresh interpreter (a __del__ raising at shutdown, a thread traceback, a urllib3 response whose file was closed first): stderr stays empty. --- .../{test_unraisable_filter.py => test_hook_exceptions_logged.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{test_unraisable_filter.py => test_hook_exceptions_logged.py} (100%) diff --git a/tests/test_unraisable_filter.py b/tests/test_hook_exceptions_logged.py similarity index 100% rename from tests/test_unraisable_filter.py rename to tests/test_hook_exceptions_logged.py