mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Install a threading.excepthook on python 3.8 and later (#38741)
Exceptions in threads were being silently discarded and never logged as the new in python 3.8 threading.excepthook was not being set.
This commit is contained in:
parent
39843319e2
commit
0d51d8660e
@ -6,6 +6,7 @@ import logging
|
||||
import logging.handlers
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
from time import monotonic
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Set
|
||||
|
||||
@ -308,6 +309,12 @@ def async_enable_logging(
|
||||
"Uncaught exception", exc_info=args # type: ignore
|
||||
)
|
||||
|
||||
if sys.version_info[:2] >= (3, 8):
|
||||
threading.excepthook = lambda args: logging.getLogger(None).exception(
|
||||
"Uncaught thread exception",
|
||||
exc_info=(args.exc_type, args.exc_value, args.exc_traceback),
|
||||
)
|
||||
|
||||
# Log errors to a file if we have write access to file or config dir
|
||||
if log_file is None:
|
||||
err_log_path = hass.config.path(ERROR_LOG_FILENAME)
|
||||
|
Loading…
x
Reference in New Issue
Block a user