mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
Small fixes for processing integration requirements (#115973)
This commit is contained in:
parent
37d329c286
commit
20adc5be70
@ -122,6 +122,11 @@ def _install_requirements_if_missing(
|
|||||||
return installed, failures
|
return installed, failures
|
||||||
|
|
||||||
|
|
||||||
|
def _set_result_unless_done(future: asyncio.Future[None]) -> None:
|
||||||
|
if not future.done():
|
||||||
|
future.set_result(None)
|
||||||
|
|
||||||
|
|
||||||
class RequirementsManager:
|
class RequirementsManager:
|
||||||
"""Manage requirements."""
|
"""Manage requirements."""
|
||||||
|
|
||||||
@ -144,16 +149,13 @@ class RequirementsManager:
|
|||||||
is invalid, RequirementNotFound if there was some type of
|
is invalid, RequirementNotFound if there was some type of
|
||||||
failure to install requirements.
|
failure to install requirements.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if done is None:
|
if done is None:
|
||||||
done = {domain}
|
done = {domain}
|
||||||
else:
|
else:
|
||||||
done.add(domain)
|
done.add(domain)
|
||||||
|
|
||||||
integration = await async_get_integration(self.hass, domain)
|
|
||||||
|
|
||||||
if self.hass.config.skip_pip:
|
if self.hass.config.skip_pip:
|
||||||
return integration
|
return await async_get_integration(self.hass, domain)
|
||||||
|
|
||||||
cache = self.integrations_with_reqs
|
cache = self.integrations_with_reqs
|
||||||
int_or_fut = cache.get(domain, UNDEFINED)
|
int_or_fut = cache.get(domain, UNDEFINED)
|
||||||
@ -170,19 +172,19 @@ class RequirementsManager:
|
|||||||
if int_or_fut is not UNDEFINED:
|
if int_or_fut is not UNDEFINED:
|
||||||
return cast(Integration, int_or_fut)
|
return cast(Integration, int_or_fut)
|
||||||
|
|
||||||
event = cache[domain] = self.hass.loop.create_future()
|
future = cache[domain] = self.hass.loop.create_future()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
integration = await async_get_integration(self.hass, domain)
|
||||||
await self._async_process_integration(integration, done)
|
await self._async_process_integration(integration, done)
|
||||||
except Exception:
|
except Exception:
|
||||||
del cache[domain]
|
del cache[domain]
|
||||||
if not event.done():
|
|
||||||
event.set_result(None)
|
|
||||||
raise
|
raise
|
||||||
|
finally:
|
||||||
|
_set_result_unless_done(future)
|
||||||
|
|
||||||
cache[domain] = integration
|
cache[domain] = integration
|
||||||
if not event.done():
|
_set_result_unless_done(future)
|
||||||
event.set_result(None)
|
|
||||||
return integration
|
return integration
|
||||||
|
|
||||||
async def _async_process_integration(
|
async def _async_process_integration(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user