Skip to content

Commit fa990a2

Browse files
committed
Added custom timeouts to bridge request to prevent timeout on Pi3B
Fixes #9
1 parent 7cdceb5 commit fa990a2

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
12+
- Added custom timeouts to bridge request to prevent timeout on Pi3B (#9)
13+
814
## [1.4.1] - 2026-03-13
915

1016
### Fixed

src/adminui/hostbridge.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
from http import HTTPStatus
33

44
import httpx
5+
from httpx import Timeout
56

67
from adminui.constants import BRIDGE_SOCKET
78

9+
# increasing httpx default (5s) as processing on host can be slow on older devices
10+
DEFAULT_TIMEOUT = Timeout(timeout=20.0)
11+
LONG_TIMETOUT = Timeout(timeout=60.0)
12+
813

914
@dataclass
1015
class BridgeResponse:
@@ -46,9 +51,11 @@ def __init__(self):
4651
# custom transport over UDS
4752
self.transport = httpx.HTTPTransport(uds=str(BRIDGE_SOCKET))
4853

49-
def do_request(self, path: str) -> BridgeResponse:
54+
def do_request(
55+
self, path: str, timeout: Timeout = DEFAULT_TIMEOUT
56+
) -> BridgeResponse:
5057
try:
51-
with httpx.Client(transport=self.transport) as client:
58+
with httpx.Client(transport=self.transport, timeout=timeout) as client:
5259
response = client.get(f"{self.api_url}{path}")
5360

5461
if response.status_code != 200:
@@ -82,7 +89,9 @@ def request_restart(self, after_seconds: int) -> BridgeResponse:
8289
def request_service_toggle(self, name: str, enable: bool) -> BridgeResponse:
8390
"""enable (not start) systemd service"""
8491
action = "enable" if enable else "disable"
85-
return self.do_request(path=f"/toggle-service/{action}/{name}")
92+
return self.do_request(
93+
path=f"/toggle-service/{action}/{name}", timeout=LONG_TIMETOUT
94+
)
8695

8796
def request_service_enabled(self, name: str) -> BridgeResponse:
8897
return self.do_request(path=f"/service-is-enabled/{name}")

0 commit comments

Comments
 (0)