Cross-platform primitives for the auto-spawning client-daemon pattern
Project description
dockpoint
Cross-platform primitives for the auto-spawning client-daemon pattern.
Like tmux, ssh-agent, gpg-agent, and docker — a frontend CLI either
connects to an existing background daemon or spawns one on demand.
dockpoint provides the low-level mechanism: a canonical, well-known
communication point that only one process can claim, with clients finding
and connecting to it.
- POSIX: Unix-domain socket with a sidecar lock file for coordination
- Windows: named pipe scoped to the current user's SID
Concepts
A Dockpoint is a claimed endpoint — the well-known rendezvous point
that only one process can hold. It accepts incoming client connections and
releases the OS resource when closed. Supports the context manager protocol.
The daemon calls dockpoint.claim() to claim a Dockpoint, then calls
.accept() on it to receive connections.
A DockpointConnection is a connected byte stream between the daemon
and one client. Clients obtain one by calling dockpoint.connect().
API
dockpoint.claim(app_name, instance="default") → Dockpoint | None
Claim the canonical endpoint and return a Dockpoint object. Returns
None if another process already owns it.
Dockpoint.accept() → DockpointConnection
Accept the next incoming client connection.
Dockpoint.close()
Release the endpoint.
dockpoint.connect(app_name, instance="default") → DockpointConnection | None
Connect to an existing endpoint. Returns None if no daemon is listening.
DockpointConnection.read(max_bytes=65536) → bytes
Read up to max_bytes from the stream.
DockpointConnection.write(data) → int
Write data to the stream. Returns the number of bytes written.
DockpointConnection.close()
Close the connection.
The pattern
dockpoint implements the rendezvous and mutual-exclusion layer for:
A: Shared protocol / definitions
B: Daemon ── calls dockpoint.claim(), serves connections
C: Frontend ── calls dockpoint.connect(), auto-spawns B if needed
The auto-spawn logic (detect → spawn → retry-connect) lives above
dockpoint, but the critical race-free primitives — atomic endpoint
claim and well-known rendezvous — are what dockpoint provides.
Usage sketch
import dockpoint
# B (daemon) side
dp = dockpoint.claim("my-app")
if dp is None:
print("Another daemon is already running.")
exit(1)
with dp:
while True:
conn = dp.accept()
data = conn.read()
conn.write(b"ack")
conn.close()
import dockpoint
# C (client) side
conn = dockpoint.connect("my-app")
if conn is None:
# No daemon — spawn one and retry
...
conn.write(b"hello\n")
reply = conn.read()
conn.close()
Why the name
A dock is a fixed, well-known place. A dockpoint is the specific spot on that dock where you tie up. One process claims the dockpoint and holds it. Others arrive at the dockpoint to communicate.
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dockpoint-0.1.0a0.tar.gz.
File metadata
- Download URL: dockpoint-0.1.0a0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee446d93687f770a786a9d1221442a1d58c7d8d00dfb9dbd9acb1dfd4ba00d06
|
|
| MD5 |
92fcfbcd97cb2e108b3593831a3d62be
|
|
| BLAKE2b-256 |
ac3e6783a08ab6d4a9a4fbce8f9ff1314995dc69fe65e464fb5c625295487478
|
File details
Details for the file dockpoint-0.1.0a0-py2.py3-none-any.whl.
File metadata
- Download URL: dockpoint-0.1.0a0-py2.py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1035b1fff7036d7cec0490bf3940949c9a73f32c252eea0ca47b659f7b421c4c
|
|
| MD5 |
6ba011ed71361b3b41172e9f26a1d483
|
|
| BLAKE2b-256 |
a753679037c15e9018c8b5a2eebdb8fd1fa5a08b9ccc5f2babe77b0c70254fb9
|