Skip to content

Commit

Permalink
Add process lock for update + fix timeout (#2215)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvizeli committed Nov 3, 2020
1 parent 28344ff commit 50e0fd1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion supervisor/hassos.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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__)

Expand All @@ -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
Expand Down Expand Up @@ -67,7 +69,7 @@ async def _download_raucb(self, version: str) -> Path:

_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()
Expand Down Expand Up @@ -128,6 +130,7 @@ def config_sync(self) -> Awaitable[None]:
)
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
Expand Down

0 comments on commit 50e0fd1

Please sign in to comment.