Skip to main content

beachcomber Python SDK

Python client for the beachcomber (comb) shell-state daemon.

Requirements

  • Python 3.9+
  • No external dependencies (stdlib ctypes binds directly to the native libbeachcomber.{so,dylib} — no subprocess, no socket code in this SDK)
  • A running comb daemon (or autostart left enabled, the default)
  • libbeachcomber.{so,dylib} discoverable — see "Library discovery" below

Installation

pip install beachcomber

Or with uv:

uv add beachcomber

Quick start

from beachcomber import Client

client = Client()

# Read a single field
result = client.get("git.branch", path="/path/to/repo")
if result.is_hit:
    print(result.data)    # "main"
    print(result.age_ms)  # 234
    print(result.stale)   # False

# Read a full provider (returns dict)
result = client.get("git", path="/path/to/repo")
if result.is_hit:
    print(result["branch"])  # "main"
    print(result["dirty"])   # False

# Force recomputation
client.refresh("git", path="/path/to/repo")

# Daemon status
status = client.status()

Sessions

For multiple queries use a session to reuse a single connection:

with client.session() as session:
    session.set_context("/path/to/repo")
    branch = session.get("git.branch")
    dirty = session.get("git.dirty")
    hostname = session.get("hostname")

Resolve and eval

client.resolve(key, cwd, env=None, overrides=None) evaluates a declared virtual field client-side; client.eval(template_str, cwd, env=None, overrides=None) evaluates a raw expression the same way. Both cwd arguments are required. The expression itself accepts a bare expression, a single {{ expr }} tag, or literal text/several tags — the first two keep the expression's natural type, the third is always a string.

Custom socket path

client = Client(socket_path="/tmp/beachcomber-1000/sock")

Library discovery

This SDK is a ctypes binding over libbeachcomber's C ABI — no socket code or wire-protocol framing lives in Python; the native library owns the connection (including the daemon socket's own auto-discovery and autostart). At import/first-use, the native library itself is located, in order:

  1. $BEACHCOMBER_LIB — exact path to the shared library.
  2. ../lib/<libname> relative to the comb binary resolved on $PATH.
  3. The platform default dynamic-linker search path.

If none resolve, LibraryDiscoveryError is raised naming every location tried — there is no silent fallback to spawning comb as a subprocess.

Socket discovery

Once the library is loaded, the daemon socket path itself is resolved by libbeachcomber (not this SDK): $BEACHCOMBER_SOCKET if set, else a stable per-user default. Pass Client(socket_path=...) to override it directly.

Exceptions

Every exception is a CombError subclass with a .kind attribute — a stable, machine-readable slug matching the C ABI envelope's error.kind (see libbeachcomber/exceptions.py), so callers should not need to string-match str(exc).

Exception .kind When raised
DaemonNotRunning daemon_not_running Daemon unreachable and autostart failed/disabled
ConnectionFailedError connection_failed An explicit socket_path couldn't be dialed
ServerError server_error Daemon returns ok: false for a request-level reason
ProtocolError io_error / parse_error / None I/O failure, malformed response, or bad envelope
TimeoutError timeout Operation timed out
BusyError busy A session/watch handle already in use by another caller
BadFlagsError bad_flags Unrecognised bit set in a get flags argument
VersionSkewError version_skew Daemon version doesn't match the loaded library's
PanicError panic The native library panicked
LibraryDiscoveryError library_discovery No candidate location yielded a loadable library
LibrarySymbolError library_symbol Loaded library is missing a required bc_* symbol
CombError varies Base class for all SDK errors

Metadata

Release files for libbeachcomber 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libbeachcomber 0.9.0
File Size Uploaded
libbeachcomber-0.9.0.tar.gz 22.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for libbeachcomber 0.9.0
File Interpreter ABI Platform
libbeachcomber-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.3 kB

Release files / libbeachcomber-0.9.0.tar.gz

Download URL libbeachcomber-0.9.0.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f8ad9b19f3df1ce8ce1da1ac51a220ef1d349acc7840c8d35aa587ed6fafbc59
BLAKE2b-256 checksum
How to use checksums
1e836e6e629b3ce8f8642aeb3d44c24dbace8b1b3c5758455021ca5ad5337aa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / libbeachcomber-0.9.0-py3-none-any.whl

Download URL libbeachcomber-0.9.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96e68129e52160dc3e01e6b31f02a2a694692b51c764db8bc7ee9d4a185131cd
BLAKE2b-256 checksum
How to use checksums
91531b79ed5de72bca584b49a83089a554636b0dfcf4c2e178cd20ec54709544
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

0.9.1

2 release files

This release

0.9.0 This release

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page