Small fixes for processing integration requirements (#115973)
This commit is contained in:
parent
37d329c286
commit
20adc5be70
1 changed files with 11 additions and 9 deletions
|
@ -122,6 +122,11 @@ def _install_requirements_if_missing(
|
|||
return installed, failures
|
||||
|
||||
|
||||
def _set_result_unless_done(future: asyncio.Future[None]) -> None:
|
||||
if not future.done():
|
||||
future.set_result(None)
|
||||
|
||||
|
||||
class RequirementsManager:
|
||||
"""Manage requirements."""
|
||||
|
||||
|
@ -144,16 +149,13 @@ class RequirementsManager:
|
|||
is invalid, RequirementNotFound if there was some type of
|
||||
failure to install requirements.
|
||||
"""
|
||||
|
||||
if done is None:
|
||||
done = {domain}
|
||||
else:
|
||||
done.add(domain)
|
||||
|
||||
integration = await async_get_integration(self.hass, domain)
|
||||
|
||||
if self.hass.config.skip_pip:
|
||||
return integration
|
||||
return await async_get_integration(self.hass, domain)
|
||||
|
||||
cache = self.integrations_with_reqs
|
||||
int_or_fut = cache.get(domain, UNDEFINED)
|
||||
|
@ -170,19 +172,19 @@ class RequirementsManager:
|
|||
if int_or_fut is not UNDEFINED:
|
||||
return cast(Integration, int_or_fut)
|
||||
|
||||
event = cache[domain] = self.hass.loop.create_future()
|
||||
future = cache[domain] = self.hass.loop.create_future()
|
||||
|
||||
try:
|
||||
integration = await async_get_integration(self.hass, domain)
|
||||
await self._async_process_integration(integration, done)
|
||||
except Exception:
|
||||
del cache[domain]
|
||||
if not event.done():
|
||||
event.set_result(None)
|
||||
raise
|
||||
finally:
|
||||
_set_result_unless_done(future)
|
||||
|
||||
cache[domain] = integration
|
||||
if not event.done():
|
||||
event.set_result(None)
|
||||
_set_result_unless_done(future)
|
||||
return integration
|
||||
|
||||
async def _async_process_integration(
|
||||
|
|
Loading…
Add table
Reference in a new issue