Prevent runtime issue during entity registration in coordinator of AVM Fritz!Tools (#108667)

prevent dictionary changed size during iteration
pull/108670/head
Michael 2024-01-22 20:26:46 +01:00 committed by GitHub
parent 80207835d7
commit 3d1751bdfa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View File

@ -315,12 +315,14 @@ class FritzBoxTools(
}
try:
await self.async_scan_devices()
for key, update_fn in self._entity_update_functions.items():
for key in list(self._entity_update_functions):
_LOGGER.debug("update entity %s", key)
entity_data["entity_states"][
key
] = await self.hass.async_add_executor_job(
update_fn, self.fritz_status, self.data["entity_states"].get(key)
self._entity_update_functions[key],
self.fritz_status,
self.data["entity_states"].get(key),
)
if self.has_call_deflections:
entity_data[

View File

@ -2,8 +2,6 @@
from unittest.mock import patch
import pytest
from homeassistant.components.fritz.const import DOMAIN
from homeassistant.components.update import DOMAIN as UPDATE_DOMAIN
from homeassistant.config_entries import ConfigEntryState
@ -49,7 +47,6 @@ async def test_update_entities_initialized(
assert len(updates) == 1
@pytest.mark.xfail(reason="Flaky test")
async def test_update_available(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,