Add process lock for update + fix timeout
@@ -12,6 +12,7 @@ from .const import URL_HASSOS_OTA
from .coresys import CoreSys, CoreSysAttributes
from .dbus.rauc import RaucState
from .exceptions import DBusError, HassOSNotSupportedError, HassOSUpdateError
+from .utils import process_lock
_LOGGER: logging.Logger = logging.getLogger(__name__)
@@ -22,6 +23,7 @@ class HassOS(CoreSysAttributes):
def __init__(self, coresys: CoreSys):
"""Initialize HassOS handler."""
self.coresys: CoreSys = coresys
+ self.lock: asyncio.Lock = asyncio.Lock()
self._available: bool = False
self._version: Optional[str] = None
self._board: Optional[str] = None
@@ -67,7 +69,7 @@ class HassOS(CoreSysAttributes):
_LOGGER.info("Fetch OTA update from %s", url)
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:
if request.status != 200:
raise HassOSUpdateError()
@@ -128,6 +130,7 @@ class HassOS(CoreSysAttributes):
)
return self.sys_host.services.restart("hassos-config.service")
+ @process_lock
async def update(self, version: Optional[str] = None) -> None:
"""Update HassOS system."""
version = version or self.latest_version
