From f3c6e846fab8007f2ba3129d7faa2bc13dcf0882 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 15 Jun 2021 12:10:47 +0200 Subject: [PATCH] Enable asyncio debugging from debugpy integration (#51880) * Optionally enable asyncio debugging from debugpy integration * Unconditionally enable asyncio debugging --- homeassistant/components/debugpy/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/debugpy/__init__.py b/homeassistant/components/debugpy/__init__.py index 98f08827c23..72f2e8db067 100644 --- a/homeassistant/components/debugpy/__init__.py +++ b/homeassistant/components/debugpy/__init__.py @@ -1,7 +1,7 @@ """The Remote Python Debugger integration.""" from __future__ import annotations -from asyncio import Event +from asyncio import Event, get_event_loop import logging from threading import Thread @@ -15,8 +15,8 @@ from homeassistant.helpers.service import async_register_admin_service from homeassistant.helpers.typing import ConfigType DOMAIN = "debugpy" -CONF_WAIT = "wait" CONF_START = "start" +CONF_WAIT = "wait" SERVICE_START = "start" CONFIG_SCHEMA = vol.Schema( @@ -43,7 +43,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def debug_start( call: ServiceCall | None = None, *, wait: bool = True ) -> None: - """Start the debugger.""" + """Enable asyncio debugging and start the debugger.""" + get_event_loop().set_debug(True) + debugpy.listen((conf[CONF_HOST], conf[CONF_PORT])) wait = conf[CONF_WAIT]