Skip to content

Commit caf7373

Browse files
authored
Merge pull request #10 from offspot/timeout
Custom timeouts to bridge request to prevent timeout on Pi3B
2 parents 7cdceb5 + fbbf575 commit caf7373

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,13 @@
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+
812

913
@dataclass
1014
class BridgeResponse:
@@ -46,9 +50,11 @@ def __init__(self):
4650
# custom transport over UDS
4751
self.transport = httpx.HTTPTransport(uds=str(BRIDGE_SOCKET))
4852

49-
def do_request(self, path: str) -> BridgeResponse:
53+
def do_request(
54+
self, path: str, timeout: Timeout = DEFAULT_TIMEOUT
55+
) -> BridgeResponse:
5056
try:
51-
with httpx.Client(transport=self.transport) as client:
57+
with httpx.Client(transport=self.transport, timeout=timeout) as client:
5258
response = client.get(f"{self.api_url}{path}")
5359

5460
if response.status_code != 200:
@@ -82,7 +88,10 @@ def request_restart(self, after_seconds: int) -> BridgeResponse:
8288
def request_service_toggle(self, name: str, enable: bool) -> BridgeResponse:
8389
"""enable (not start) systemd service"""
8490
action = "enable" if enable else "disable"
85-
return self.do_request(path=f"/toggle-service/{action}/{name}")
91+
return self.do_request(
92+
path=f"/toggle-service/{action}/{name}",
93+
timeout=Timeout(timeout=20.0, read=60.0),
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)