UnixServer(path, handler, *, mode=0o600, backlog=16)— threaded Unix-domain-socket server speaking JSON lines. Auto-cleans stale socket files; refuses to overwrite a live socket. Handler exceptions are returned to the client as{"error", "type"}envelopes; the server keeps serving. Context-manager protocol.UnixClient(path, *, timeout=5.0, retries=3, retry_backoff=0.5)— synchronous client withrequest()(round-trip) andnotify()(fire-and-forget). Exponential backoff retry onConnectionRefusedError/FileNotFoundError.JsonLineProtocol— framing helper.encode(payload) → bytesanddecode_stream(reader)generator over a binary stream.FifoChannel(path, *, mode=0o600)— JSON-line over a named pipe. Auto-creates the FIFO; non-blockingsend()(raisesBrokenPipeErrorwhen no reader is attached); blockingrecv().pidfile(path)— context manager that writes the current PID, takes an exclusiveflockadvisory lock, and removes the file on exit. RaisesBlockingIOErrorif another process already holds the lock — drop-in "don't start twice" guard for sidecar daemons.
- Stdlib-only:
socket,threading,fcntl,os,json. - Linux is the primary target; BSD/macOS are best-effort.
- Permissions default to
0o600everywhere (owner-only).