Update link when IO in event loop (#31519)
parent
8d429d7676
commit
a3b3924e21
|
@ -365,13 +365,17 @@ class Entity(ABC):
|
|||
|
||||
if end - start > 0.4 and not self._slow_reported:
|
||||
self._slow_reported = True
|
||||
url = "https://github.com/home-assistant/home-assistant/issues?q=is%3Aopen+is%3Aissue"
|
||||
if self.platform:
|
||||
url += f"+label%3A%22integration%3A+{self.platform.platform_name}%22"
|
||||
|
||||
_LOGGER.warning(
|
||||
"Updating state for %s (%s) took %.3f seconds. "
|
||||
"Please report platform to the developers at "
|
||||
"https://goo.gl/Nvioub",
|
||||
"Please create a bug report at %s",
|
||||
self.entity_id,
|
||||
type(self),
|
||||
end - start,
|
||||
url,
|
||||
)
|
||||
|
||||
# Overwrite properties that have been set in the config file.
|
||||
|
|
|
@ -661,3 +661,22 @@ async def test_capability_attrs(hass):
|
|||
assert state is not None
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
assert state.attributes["always"] == "there"
|
||||
|
||||
|
||||
async def test_warn_slow_write_state(hass, caplog):
|
||||
"""Check that we log a warning if reading properties takes too long."""
|
||||
mock_entity = entity.Entity()
|
||||
mock_entity.hass = hass
|
||||
mock_entity.entity_id = "comp_test.test_entity"
|
||||
mock_entity.platform = MagicMock(platform_name="hue")
|
||||
|
||||
with patch("homeassistant.helpers.entity.timer", side_effect=[0, 10]):
|
||||
mock_entity.async_write_ha_state()
|
||||
|
||||
assert (
|
||||
"Updating state for comp_test.test_entity "
|
||||
"(<class 'homeassistant.helpers.entity.Entity'>) "
|
||||
"took 10.000 seconds. Please create a bug report at "
|
||||
"https://github.com/home-assistant/home-assistant/issues?"
|
||||
"q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+hue%22"
|
||||
) in caplog.text
|
||||
|
|
Loading…
Reference in New Issue