mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
Log unhandled loop exception traces when asyncio debug is on (#57602)
This commit is contained in:
@@ -5,6 +5,7 @@ import asyncio
|
||||
import dataclasses
|
||||
import logging
|
||||
import threading
|
||||
import traceback
|
||||
from typing import Any
|
||||
|
||||
from homeassistant import bootstrap
|
||||
@@ -86,9 +87,15 @@ def _async_loop_exception_handler(_: Any, context: dict[str, Any]) -> None:
|
||||
if exception := context.get("exception"):
|
||||
kwargs["exc_info"] = (type(exception), exception, exception.__traceback__)
|
||||
|
||||
logging.getLogger(__package__).error(
|
||||
"Error doing job: %s", context["message"], **kwargs # type: ignore
|
||||
)
|
||||
logger = logging.getLogger(__package__)
|
||||
if source_traceback := context.get("source_traceback"):
|
||||
stack_summary = "".join(traceback.format_list(source_traceback))
|
||||
logger.error(
|
||||
"Error doing job: %s: %s", context["message"], stack_summary, **kwargs # type: ignore
|
||||
)
|
||||
return
|
||||
|
||||
logger.error("Error doing job: %s", context["message"], **kwargs) # type: ignore
|
||||
|
||||
|
||||
async def setup_and_run_hass(runtime_config: RuntimeConfig) -> int:
|
||||
|
||||
Reference in New Issue
Block a user