Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Added custom timeouts to bridge request to prevent timeout on Pi3B (#9)

## [1.4.1] - 2026-03-13

### Fixed
Expand Down
15 changes: 12 additions & 3 deletions src/adminui/hostbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
from http import HTTPStatus

import httpx
from httpx import Timeout

from adminui.constants import BRIDGE_SOCKET

# increasing httpx default (5s) as processing on host can be slow on older devices
DEFAULT_TIMEOUT = Timeout(timeout=20.0)


@dataclass
class BridgeResponse:
Expand Down Expand Up @@ -46,9 +50,11 @@ def __init__(self):
# custom transport over UDS
self.transport = httpx.HTTPTransport(uds=str(BRIDGE_SOCKET))

def do_request(self, path: str) -> BridgeResponse:
def do_request(
self, path: str, timeout: Timeout = DEFAULT_TIMEOUT
) -> BridgeResponse:
try:
with httpx.Client(transport=self.transport) as client:
with httpx.Client(transport=self.transport, timeout=timeout) as client:
response = client.get(f"{self.api_url}{path}")

if response.status_code != 200:
Expand Down Expand Up @@ -82,7 +88,10 @@ def request_restart(self, after_seconds: int) -> BridgeResponse:
def request_service_toggle(self, name: str, enable: bool) -> BridgeResponse:
"""enable (not start) systemd service"""
action = "enable" if enable else "disable"
return self.do_request(path=f"/toggle-service/{action}/{name}")
return self.do_request(
path=f"/toggle-service/{action}/{name}",
timeout=Timeout(timeout=20.0, read=60.0),
)

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