Skip to content

Commit d5bd8b9

Browse files
committed
Dont cache integrations that are not found (#23316)
1 parent 34c0310 commit d5bd8b9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

homeassistant/loader.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,13 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\
161161
await int_or_evt.wait()
162162
int_or_evt = cache.get(domain, _UNDEF)
163163

164-
if int_or_evt is _UNDEF:
165-
pass
166-
elif int_or_evt is None:
167-
raise IntegrationNotFound(domain)
168-
else:
164+
# When we have waited and it's _UNDEF, it doesn't exist
165+
# We don't cache that it doesn't exist, or else people can't fix it
166+
# and then restart, because their config will never be valid.
167+
if int_or_evt is _UNDEF:
168+
raise IntegrationNotFound(domain)
169+
170+
if int_or_evt is not _UNDEF:
169171
return cast(Integration, int_or_evt)
170172

171173
event = cache[domain] = asyncio.Event()
@@ -197,7 +199,12 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\
197199
return integration
198200

199201
integration = Integration.resolve_legacy(hass, domain)
200-
cache[domain] = integration
202+
if integration is not None:
203+
cache[domain] = integration
204+
else:
205+
# Remove event from cache.
206+
cache.pop(domain)
207+
201208
event.set()
202209

203210
if not integration:

0 commit comments

Comments
 (0)