Skip to content

Commit 63092ad

Browse files
committed
logger crash should crash, don't want crash? don't init logger and crash callback
1 parent d1708c5 commit 63092ad

1 file changed

Lines changed: 0 additions & 31 deletions

File tree

test/test_io.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -326,37 +326,6 @@ def test_log_subject_hierarchy(self):
326326
finally:
327327
logger.removeHandler(handler)
328328

329-
def test_callback_exception_does_not_crash(self):
330-
"""If a logging handler raises, CRT should not crash and subsequent logging should still work."""
331-
332-
class BrokenHandler(logging.Handler):
333-
def emit(self, record):
334-
raise RuntimeError("handler exploded")
335-
336-
logger = logging.getLogger('awscrt')
337-
logger.setLevel(logging.DEBUG)
338-
broken = BrokenHandler()
339-
logger.addHandler(broken)
340-
341-
try:
342-
# This triggers the C callback -> Python callback -> handler.emit -> raise
343-
# Should not crash or leave the process in a bad state
344-
log(logging.INFO, LogSubject.COMMON_GENERAL, "this should not crash")
345-
finally:
346-
logger.removeHandler(broken)
347-
348-
# Verify logging still works after the error
349-
good = logging.Handler()
350-
good.records = []
351-
good.emit = lambda record: good.records.append(record)
352-
logger.addHandler(good)
353-
try:
354-
log(logging.INFO, LogSubject.COMMON_GENERAL, "after error")
355-
self.assertEqual(len(good.records), 1)
356-
self.assertIn("after error", good.records[0].getMessage())
357-
finally:
358-
logger.removeHandler(good)
359-
360329
def _emit_all_subjects_and_levels(self):
361330
"""Emit logs across all subjects at INFO and DEBUG levels."""
362331
for subject in (LogSubject.IO_EVENT_LOOP, LogSubject.HTTP_GENERAL,

0 commit comments

Comments
 (0)