Fix race when handling MQTT discovery messages (#44730)
* Fix race when handling MQTT discovery messages * Lint * retrigger checks
This commit is contained in:
parent
43474762b2
commit
34bd70aee6
19 changed files with 368 additions and 59 deletions
|
@ -47,7 +47,10 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.reload import async_setup_reload_service
|
||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||
|
||||
|
@ -66,7 +69,7 @@ from . import (
|
|||
)
|
||||
from .. import mqtt
|
||||
from .debug_info import log_messages
|
||||
from .discovery import MQTT_DISCOVERY_NEW, clear_discovery_hash
|
||||
from .discovery import MQTT_DISCOVERY_DONE, MQTT_DISCOVERY_NEW, clear_discovery_hash
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -259,7 +262,11 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
hass, config, async_add_entities, config_entry, discovery_data
|
||||
)
|
||||
except Exception:
|
||||
clear_discovery_hash(hass, discovery_data[ATTR_DISCOVERY_HASH])
|
||||
discovery_hash = discovery_data[ATTR_DISCOVERY_HASH]
|
||||
clear_discovery_hash(hass, discovery_hash)
|
||||
async_dispatcher_send(
|
||||
hass, MQTT_DISCOVERY_DONE.format(discovery_hash), None
|
||||
)
|
||||
raise
|
||||
|
||||
async_dispatcher_connect(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue