From 72bbe2203e0496c41e027aa34b061347fecf0091 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 22 Apr 2019 22:06:58 -0700 Subject: [PATCH] Dont cache integrations that are not found (#23316) --- homeassistant/loader.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/homeassistant/loader.py b/homeassistant/loader.py index ed2ea83afb0..fb2c1bae894 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -161,11 +161,13 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\ await int_or_evt.wait() int_or_evt = cache.get(domain, _UNDEF) - if int_or_evt is _UNDEF: - pass - elif int_or_evt is None: - raise IntegrationNotFound(domain) - else: + # When we have waited and it's _UNDEF, it doesn't exist + # We don't cache that it doesn't exist, or else people can't fix it + # and then restart, because their config will never be valid. + if int_or_evt is _UNDEF: + raise IntegrationNotFound(domain) + + if int_or_evt is not _UNDEF: return cast(Integration, int_or_evt) event = cache[domain] = asyncio.Event() @@ -197,7 +199,12 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\ return integration integration = Integration.resolve_legacy(hass, domain) - cache[domain] = integration + if integration is not None: + cache[domain] = integration + else: + # Remove event from cache. + cache.pop(domain) + event.set() if not integration: