mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-16 21:56:29 +00:00
Add process lock for update + fix timeout (#2215)
This commit is contained in:
parent
28344ff5f3
commit
50e0fd159f
@ -12,6 +12,7 @@ from .const import URL_HASSOS_OTA
|
|||||||
from .coresys import CoreSys, CoreSysAttributes
|
from .coresys import CoreSys, CoreSysAttributes
|
||||||
from .dbus.rauc import RaucState
|
from .dbus.rauc import RaucState
|
||||||
from .exceptions import DBusError, HassOSNotSupportedError, HassOSUpdateError
|
from .exceptions import DBusError, HassOSNotSupportedError, HassOSUpdateError
|
||||||
|
from .utils import process_lock
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ class HassOS(CoreSysAttributes):
|
|||||||
def __init__(self, coresys: CoreSys):
|
def __init__(self, coresys: CoreSys):
|
||||||
"""Initialize HassOS handler."""
|
"""Initialize HassOS handler."""
|
||||||
self.coresys: CoreSys = coresys
|
self.coresys: CoreSys = coresys
|
||||||
|
self.lock: asyncio.Lock = asyncio.Lock()
|
||||||
self._available: bool = False
|
self._available: bool = False
|
||||||
self._version: Optional[str] = None
|
self._version: Optional[str] = None
|
||||||
self._board: Optional[str] = None
|
self._board: Optional[str] = None
|
||||||
@ -67,7 +69,7 @@ class HassOS(CoreSysAttributes):
|
|||||||
|
|
||||||
_LOGGER.info("Fetch OTA update from %s", url)
|
_LOGGER.info("Fetch OTA update from %s", url)
|
||||||
try:
|
try:
|
||||||
timeout = aiohttp.ClientTimeout(total=600)
|
timeout = aiohttp.ClientTimeout(total=60 * 60, connect=180)
|
||||||
async with self.sys_websession.get(url, timeout=timeout) as request:
|
async with self.sys_websession.get(url, timeout=timeout) as request:
|
||||||
if request.status != 200:
|
if request.status != 200:
|
||||||
raise HassOSUpdateError()
|
raise HassOSUpdateError()
|
||||||
@ -128,6 +130,7 @@ class HassOS(CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
return self.sys_host.services.restart("hassos-config.service")
|
return self.sys_host.services.restart("hassos-config.service")
|
||||||
|
|
||||||
|
@process_lock
|
||||||
async def update(self, version: Optional[str] = None) -> None:
|
async def update(self, version: Optional[str] = None) -> None:
|
||||||
"""Update HassOS system."""
|
"""Update HassOS system."""
|
||||||
version = version or self.latest_version
|
version = version or self.latest_version
|
||||||
|
Loading…
x
Reference in New Issue
Block a user