Dont cache integrations that are not found (#23316)

This commit is contained in:
Paulus Schoutsen 2019-04-22 22:06:58 -07:00 committed by GitHub
parent 2a720efbd4
commit 72bbe2203e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
# 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:
pass
elif int_or_evt is None:
raise IntegrationNotFound(domain)
else:
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)
if integration is not None:
cache[domain] = integration
else:
# Remove event from cache.
cache.pop(domain)
event.set()
if not integration: