pympacds-http
HTTP client service for pympacds. Sends data over HTTP on behalf of other services and exposes it over D-Bus, with automatic retry and optional mutual TLS.
Features
- Fire-and-forget D-Bus API:
send,download, andrequesteach return a random request token immediately; the result is delivered asynchronously via therequest_completed(token, result)signal, so callers correlate a call with its outcome by token. - A single pooled
aiohttp.ClientSession(native asyncio, no thread offloading), created at startup with no network I/O and closed on shutdown. - Automatic retry of transient failures (network error, timeout, HTTP 5xx)
with exponential backoff (
retries,retry_backoff_s). - TLS verification control (
tls_verify) plus mutual TLS viatls_certfile/tls_keyfile(must be provided together). download/requestwith adownload_pathwrite the response body atomically to disk (temp file + rename) for binary/large downloads.- Runtime configuration:
[http]keys are writable via the frameworkConfigContract. - Exports the framework
HealthContract(always) andConfigContract(opt-in via[dbus] contract_config = true) alongside the HTTP contract.
Why aiohttp
The service uses aiohttp because it is asyncio
native: requests run directly on the framework's single event loop with no
thread offloading. It is isolated in this service's own package, so the core
pympacds framework keeps its zero-dependency property (the core's
httpconfprov middleware continues to use the stdlib urllib.request).
Installation
Using PIP
pip install pympacds-http
Using pip installs the Python package only — the D-Bus policy and systemd unit
are not installed. You can still run the service directly with
pympacds-http -c /etc/pympacds/http.ini, or register and enable it
system-wide with the admin script. Since there is no packaged unit, pass the
pip-installed executable via --program so the unit is generated:
sudo pympacds-admin setup # one-time: user, log dir, D-Bus policy
sudo pympacds-admin install http \
--program "$(command -v pympacds-http)" \
--config /etc/pympacds/http.ini --start
Alternatively, install the Debian package (see below), which already ships the unit and policy.
Using PPA
Debian packages are provided through launchpad ppa (dargor0/mpacds):
sudo add-apt-repository ppa:dargor0/mpacds
sudo apt update
sudo apt install python3-pympacds-http
The package installs the service system-wide (executable, systemd unit, D-Bus
policy, and the http.ini.example config) and depends on python3-pympacds.
Repository has been tested on Ubuntu (plucky, resolute, stonking) and Debian (stable, testing, unstable).
Configuration
The service reads its parameters from the [http] INI section (see
config/http.ini.example). Key options:
| Key | Default | Description |
|---|---|---|
timeout_s |
10 |
Per-request timeout |
retries |
3 |
Number of retry attempts |
retry_backoff_s |
1 |
Initial backoff (exponential) between retries |
tls_verify |
true |
Verify TLS certificates |
tls_certfile / tls_keyfile |
"" |
Client cert/key (PEM) for mutual TLS |
max_redirects |
5 |
Maximum redirects to follow |
default_url |
"" |
Target URL used by send() (empty = send() fails) |
default_method |
POST |
Default HTTP method used by send() |
default_headers |
"" |
Default headers (JSON object) used by send() |
Run with:
pympacds-http -c /etc/pympacds/http.ini
D-Bus API
Interface org.pympacds.HTTP at object path /org/pympacds/http:
| Member | Type | Description |
|---|---|---|
send(payload) |
send(s) -> s |
Send with default url/method/headers; returns a token |
download(payload, download_path) |
download(ss) -> s |
Like send, but saves the body to download_path |
request(method, url, headers, body, download_path) |
request(sssss) -> s |
Explicit request; empty download_path = return body |
request_completed(token, result) |
signal (ss) |
Emitted on completion; carries the token and JSON result |
All sends are fire-and-forget: the method returns immediately with a
randomized token, the request runs asynchronously, and request_completed is
emitted with the full JSON outcome:
{
"status_code": 200,
"url": "https://example.com/api",
"elapsed_ms": 123,
"body": "...",
"download_path": null,
"bytes_written": null,
"error": null
}
The framework HealthContract (at .../health) and ConfigContract
([dbus] contract_config = true) are also exported.
Metadata
Release files for pympacds-http 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pympacds_http-0.1.2.tar.gz | 15.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pympacds_http-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.9 kB
Release files / pympacds_http-0.1.2.tar.gz
| Download URL | pympacds_http-0.1.2.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fc052184daa88c431efed7ca873c687e3bcfe00b55e916da662e04ae8d1ee44
|
|
BLAKE2b-256 checksum How to use checksums |
6690176f979f16d34f6243718ceec8522257661abdfd1557447cb9b78f10eddf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / pympacds_http-0.1.2-py3-none-any.whl
| Download URL | pympacds_http-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
823b9646e264e8941bb5add93978868d5904dcfc3789bed82d66f33a65164b42
|
|
BLAKE2b-256 checksum How to use checksums |
ee60101323e786ac9c2857a5e241af420c60912813a3320834e49d0b9f3db88d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|