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
pip install pympacds-http
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.0
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.0.tar.gz | 13.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pympacds_http-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.4 kB
Release files / pympacds_http-0.1.0.tar.gz
| Download URL | pympacds_http-0.1.0.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f745a7ca91529c41f9aedba169c8469e820c43c57a775483448f66910b91cc13
|
|
BLAKE2b-256 checksum How to use checksums |
e1dd441d54466ca89311ae62beb765672bd3ab7d7a96989b41f3744cb1512c17
|
| 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.0-py3-none-any.whl
| Download URL | pympacds_http-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d62c443b4c4e9db46d23ca4d85da0ee52e61e94e4612b08f17f95ef0cbeb9e8
|
|
BLAKE2b-256 checksum How to use checksums |
51807d0b00ac32695919d4f6517f3a4f61a4140adfa6602aa35eeeb0b6f51839
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|