Dont cache integrations that are not found ()

pull/23353/head
Paulus Schoutsen 2019-04-22 22:06:58 -07:00
parent 34c03109e5
commit d5bd8b9405
1 changed files with 13 additions and 6 deletions
homeassistant

View File

@ -161,11 +161,13 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\
await int_or_evt.wait() await int_or_evt.wait()
int_or_evt = cache.get(domain, _UNDEF) int_or_evt = cache.get(domain, _UNDEF)
if int_or_evt is _UNDEF: # When we have waited and it's _UNDEF, it doesn't exist
pass # We don't cache that it doesn't exist, or else people can't fix it
elif int_or_evt is None: # and then restart, because their config will never be valid.
raise IntegrationNotFound(domain) if int_or_evt is _UNDEF:
else: raise IntegrationNotFound(domain)
if int_or_evt is not _UNDEF:
return cast(Integration, int_or_evt) return cast(Integration, int_or_evt)
event = cache[domain] = asyncio.Event() event = cache[domain] = asyncio.Event()
@ -197,7 +199,12 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\
return integration return integration
integration = Integration.resolve_legacy(hass, domain) 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() event.set()
if not integration: if not integration: