Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add process lock for update + fix timeout #2215

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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