Commlink
Commlink exposes a lightweight Remote Procedure Call (RPC) layer on top of ZeroMQ that lets you interact with objects running in a different process or host as if they were local. You can wrap any existing object with a single line and obtain a client-side proxy that transparently mirrors attribute access, mutation, and callable invocation for anything that can be pickled. Simple publisher/subscriber helpers are also available for broadcast-style messaging when you need them.
Installation
pip install commlink
RPC quickstart
Server
import numpy as np
from commlink import RPCServer
class Robot:
def __init__(self):
self.name = "robot_arm"
self.target = np.zeros(7)
self.joint_angles = np.zeros(7)
def move_to(self, target):
"""Pretend to command the arm and update internal state."""
self.target = target
self.joint_angles = target # Pretend we reached the target.
return f"moving to {target}"
def start_background_planner(self):
"""Threads inside the object are fine; RPC will just call into them."""
# Launch your own planner thread here; omitted for brevity.
return "planner started"
if __name__ == "__main__":
# Wrap the robot with a one-line RPC server. The server runs in a background thread by default.
robot = Robot()
server = RPCServer(robot, port=6000)
server.start()
Client
from commlink import RPCClient
# Connect to the robot and use it like it's local (up to anything pickle-able)
robot = RPCClient("localhost", port=6000)
print(robot.name) # "robot_arm"
robot.name = "something_else"
print(robot.name) # "something_else"
robot.move_to(np.ones(7))
print(robot.joint_angles)
# Kick off threaded work that lives inside the remote object.
print(robot.start_background_planner())
# When you're finished, politely stop the remote server.
robot.stop_server()
RPC capabilities
- Transparent calls – Functions and methods execute remotely with arbitrary pickle-able arguments and return values.
- Attribute access – Reading or setting attributes forwards the operation to the remote object.
- Drop-in adoption – Wrap any pre-existing object with
RPCServer(obj, ...)and obtain a live proxy by instantiatingRPCClient(host, port). - Thread-friendly –
RPCServercan run in a background thread, and the wrapped object can manage its own worker threads or loops without special handling.
Publisher/subscriber helpers
If you also need broadcast-style messaging (images, poses, strings), Commlink ships with simple ZeroMQ publishers and subscribers:
import numpy as np
from commlink import Publisher, Subscriber
pub = Publisher("*", port=5555)
sub = Subscriber("localhost", port=5555, topics=["rgb_image", "depth_image", "camera_pose", "info"])
# Publish rich data using dict-style access.
pub["rgb_image"] = np.random.randn(3, 224, 224)
pub["depth_image"] = np.random.randn(1, 224, 224)
pub["camera_pose"] = np.random.randn(4, 4)
pub["info"] = "helloworld"
# Receive them on the subscriber side.
print(sub["rgb_image"].shape)
print(sub["depth_image"].shape)
print(sub["camera_pose"].shape)
print(sub["info"])
Compression
Publisher, Subscriber, RPCServer, and RPCClient all accept an optional
compression argument. Supported values: None (default), "zstd", "lz4".
Both codecs ship with Commlink -- no extras to install.
pub = Publisher("*", port=5555, compression="zstd")
sub = Subscriber("localhost", port=5555, topics=["frame"], compression="zstd")
The codec is bound at construction time, so the per-message hot path has no
extra branching. The wire format is self-describing (each frame carries a 1-byte
codec tag), which means the receiver can decode any codec regardless of how it
was configured -- mixing compression=None and compression="zstd" between
sender and receiver still works. This also preserves backward compatibility
with publishers that predate the compression option.
For a streaming benchmark that reports wire size, latency, jitter, and bandwidth across codecs:
python benchmarks/benchmark_compression.py --iters 100
Development
Run the automated test suite with:
pytest
License
Commlink is distributed under the terms of the MIT License.
Metadata
Release files for commlink 0.4.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 | Provenance | Actions |
|---|---|---|---|---|
| commlink-0.4.2.tar.gz | 25.9 kB | Without provenance | Details for commlink-0.4.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| commlink-0.4.2-py3-none-any.whl | Python 3 | none | any | Details for commlink-0.4.2-py3-none-any.whl |
Total release size: 44.4 kB
Release files / commlink-0.4.2.tar.gz
| Download URL | commlink-0.4.2.tar.gz |
|---|---|
| Size | 25.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68ac64abfea8eb3bdc844beaff0eb278b9920df48f9fa2f80b6a3581719c1312
|
|
BLAKE2b-256 checksum How to use checksums |
3838e39fc820ef98998d242e6435925e5fb5ca90ebf0ef64c049df512663cae7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / commlink-0.4.2-py3-none-any.whl
| Download URL | commlink-0.4.2-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b43d309071b14d70aea6e2484af6ab6bdf7c5fe0d5221bf47ee13c0e94be8307
|
|
BLAKE2b-256 checksum How to use checksums |
c2b390813e5da23c6c67c47694749d2f147521aa9be51b944896a395dbdccb2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for commlink 0.4.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.