From f5fc2053847d3054d36d3348d21e7de060342698 Mon Sep 17 00:00:00 2001 From: suchmememanyskill <38142618+suchmememanyskill@users.noreply.github.com> Date: Sun, 30 Oct 2022 00:13:19 +0200 Subject: Add timeout to get tabs request, wait for network online target before booting decky (#239) * Add timeout to tabs get request * Wait for network interfaces to be ready before booting decky --- backend/injector.py | 6 +++++- dist/install_prerelease.sh | 2 ++ dist/install_release.sh | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/injector.py b/backend/injector.py index 39b86f9a..82ed6ed4 100644 --- a/backend/injector.py +++ b/backend/injector.py @@ -7,6 +7,7 @@ from typing import List from aiohttp import ClientSession from aiohttp.client_exceptions import ClientConnectorError +from asyncio.exceptions import TimeoutError import uuid BASE_ADDRESS = "http://localhost:8080" @@ -341,12 +342,15 @@ async def get_tabs() -> List[Tab]: while True: try: - res = await web.get(f"{BASE_ADDRESS}/json") + res = await web.get(f"{BASE_ADDRESS}/json", timeout=3) except ClientConnectorError: logger.debug("ClientConnectorError excepted.") logger.debug("Steam isn't available yet. Wait for a moment...") logger.error(format_exc()) await sleep(5) + except TimeoutError: + logger.warn(f"The request to {BASE_ADDRESS}/json timed out") + await sleep(1) else: break diff --git a/dist/install_prerelease.sh b/dist/install_prerelease.sh index cdab980a..8b9be30e 100644 --- a/dist/install_prerelease.sh +++ b/dist/install_prerelease.sh @@ -30,6 +30,8 @@ rm -f "/etc/systemd/system/plugin_loader.service" cat > "/etc/systemd/system/plugin_loader.service" <<- EOM [Unit] Description=SteamDeck Plugin Loader +After=network-online.target +Wants=network-online.target [Service] Type=simple User=root diff --git a/dist/install_release.sh b/dist/install_release.sh index 3656e10e..f4f1f91d 100644 --- a/dist/install_release.sh +++ b/dist/install_release.sh @@ -30,6 +30,8 @@ rm -f "/etc/systemd/system/plugin_loader.service" cat > "/etc/systemd/system/plugin_loader.service" <<- EOM [Unit] Description=SteamDeck Plugin Loader +After=network-online.target +Wants=network-online.target [Service] Type=simple User=root -- cgit v1.2.3