RPyC -- Remote Python Call
RPyC is a transparent, symmetric Python library for remote procedure calls,
clustering, and distributed computing. Object-proxying makes remote objects
behave like local ones.
Use the Read tool to load referenced files identified as relevant for full details.
Install: pip install rpyc
Default ports: Classic 18812, SSL 18821, Registry 18811
Python: CPython 3.7+ (no Python 2<->3 crossing)
Dependencies: None for core; plumbum for zero-deploy; pywin32 for PipeStream on Windows
Repository: https://github.com/tomerfiliba-org/rpyc
When to Use
- Remote testing -- run tests centrally, operations happen on remote machines
- Administration -- control heterogeneous machines from one place using Python
- Remote hardware -- access
ctypes, /dev files, drivers on remote machines transparently
- Parallel execution -- overcome GIL by distributing work across RPyC processes
- Distributed computation -- platform-agnostic foundation for clustering
- Remote services -- implement secure RPC services without heavyweight frameworks
- Monkey-patching -- replace local modules with remote ones to cross network boundaries
When NOT to Use
- Need a REST/HTTP API (use Flask, FastAPI)
- Need language-agnostic RPC (use gRPC, Thrift)
- Need message queuing (use Celery, RabbitMQ)
- Untrusted clients over the Internet without SSL/SSH wrapping
Which File Do I Need?
Reference files (distilled, code-rich summaries):
| I need to... |
Read |
Classic mode -- rpyc.classic.connect(), conn.modules, conn.teleport(), tutorials 1/2/4 |
classic-and-tutorials.md |
Services -- rpyc.Service, exposed_, ThreadedServer, rpyc.discover(), tutorial 3 |
services-and-servers.md |
Async -- rpyc.async_(), AsyncResult, rpyc.timed(), BgServingThread, tutorial 5 |
async-and-events.md |
Security -- SSLAuthenticator, rpyc.ssl_connect(), restricted(), DeployedServer |
security-and-connections.md |
API -- rpyc.connect(), Connection, Service, Netref, factory functions, classpartial() |
api-reference.md |
| Demos -- echo, chat, filemon, sharing, async_client, boilerplate patterns |
demos-and-patterns.md |
Config -- protocol_config, rpyc_classic.py, rpyc_registry.py, Wireshark debugging |
config-and-cli.md |
Try distilled references (above) first. Use upstream docs below only when more detail is needed.
Original upstream docs (for additional detail beyond the reference files):
| Topic |
Key API / search terms |
Read |
| Theory of operation |
boxing by-value/by-reference, netref proxying, address space unification, symmetry |
docs/theory.md |
| Classic mode |
rpyc.classic.connect(), conn.modules, conn.execute(), conn.builtin, rpyc_classic.py |
docs/classic.md |
| Services |
rpyc.Service, exposed_ prefix, @rpyc.exposed, @rpyc.service, conn.root, on_connect(), on_disconnect(), ALIASES, VoidService |
docs/services.md |
| Servers & registry |
ThreadedServer, ForkingServer, ClassicService, rpyc_classic.py flags (-m, -p, --register), rpyc_registry.py |
docs/servers.md |
| Async & background |
rpyc.async_(), AsyncResult (.ready, .value, .wait(), .set_expiry(), .add_callback()), rpyc.timed(), BgServingThread |
docs/async.md |
| Security model |
restricted(), allow_public_attrs, _rpyc_getattr, _rpyc_setattr, _rpyc_delattr, capability-based security |
docs/security.md |
| SSL/TLS |
SSLAuthenticator, rpyc.ssl_connect(), keyfile, certfile, certificate/key setup |
docs/secure-connection.md |
| Zero-deploy (SSH) |
DeployedServer, MultiServerDeployment, SshMachine, .classic_connect(), .classic_connect_all(), plumbum |
docs/zerodeploy.md |
| How-to recipes |
redirected_stdio(), rpyc.classic.pm(), stdio redirection, tunneling over bridges, monkey-patching |
docs/howto.md |
| Advanced debugging |
pyenv multi-version testing, Docker testing, Wireshark capture, rpyc_classic.py --host |
docs/advanced-debugging.md |
| Tutorial 1: Classic |
rpyc.classic.connect(), conn.modules, conn.builtins, conn.namespace, conn.teleport(), conn.eval(), conn.execute() |
tutorial/tut1.md |
| Tutorial 2: Netrefs |
netref, isinstance(), exception propagation, import_custom_exceptions, OneShotServer, protocol_config= |
tutorial/tut2.md |
| Tutorial 3: Services |
rpyc.Service, ThreadedServer, OneShotServer, rpyc.discover(), rpyc.list_services(), rpyc.connect_by_service(), classpartial |
tutorial/tut3.md |
| Tutorial 4: Callbacks |
callbacks as first-class objects, passing local functions to remote, symmetric protocol |
tutorial/tut4.md |
| Tutorial 5: Async |
rpyc.async_(), AsyncResult (.error), BgServingThread, conn.poll_all(), conn.serve, event producer/consumer |
tutorial/tut5.md |
| Use cases |
remote testing, administration, hardware access, GIL workaround, distributed computation, clustering |
docs/usecases.md |
| Release process |
hatch build, hatch publish, git tagging, PyPI, semantic versioning, CHANGELOG |
docs/rpyc-release-process.md |
| Per-module API |
core.brine, core.protocol, core.netref, core.service, core.stream, utils.server, utils.registry, utils.authenticators, utils.factory, utils.classic, utils.zerodeploy |
api/*.md (11 files) |
Quick Reference
Connect (Classic Mode)
import rpyc
conn = rpyc.classic.connect("hostname") # port 18812
conn.modules.os.listdir("/tmp") # remote module access
conn.builtins.open("/etc/hostname").read() # remote builtins
Create a Service
import rpyc
from rpyc.utils.server import ThreadedServer
class MyService(rpyc.Service):
def on_connect(self, conn): pass
def on_disconnect(self, conn): pass
def exposed_add(self, a, b):
return a + b
ThreadedServer(MyService, port=18861).start()
Connect to a Service
conn = rpyc.connect("hostname", 18861)
conn.root.add(3, 4) # => 7
For async, timed calls, BgServingThread examples see async-and-events.md.
For SSL, zero-deploy, service discovery examples see security-and-connections.md and services-and-servers.md.
Common Mistakes
| Mistake |
Fix |
rpyc.async_(conn.root.fn)(args) -- weak-ref lost |
Store wrapper: afn = rpyc.async_(conn.root.fn); afn(args) |
| Expecting async execution order |
No order guarantee for multiple async requests |
allow_all_attrs on public server |
Use allow_exposed_attrs (default) + capability-based access |
No BgServingThread when using callbacks |
Server callbacks won't process unless client serves requests |
Overriding __init__ on Service class |
Use on_connect(self, conn) instead |
| Passing class instance vs class to ThreadedServer |
ThreadedServer(MyService) = per-connection; ThreadedServer(MyService()) = shared |
Exposing objects with sys references |
Attacker can traverse to sys.modules; use restricted() wrapper |
| Cross-Python-version connections (2<->3) |
Not supported; 3.x<->3.y works if shared types/modules used |
| Not closing connections (resource leak) |
Use with rpyc.connect(...) as conn: or try/finally with conn.close() |
Key Concepts
Transparent (remote objects behave local) | Symmetric (both ends serve requests) | Boxing (immutables by value, rest by reference as netrefs) | Capability-based security (pass specific objects, not broad access)
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: bitranox-bx-skills-bx-rpyc3description: RPyC -- Remote Python Call4---56# RPyC -- Remote Python Call78RPyC is a transparent, symmetric Python library for remote procedure calls,9clustering, and distributed computing. Object-proxying makes remote objects10behave like local ones.1112Use the Read tool to load referenced files identified as relevant for full details.1314**Install:** `pip install rpyc`15**Default ports:** Classic `18812`, SSL `18821`, Registry `18811`16**Python:** CPython 3.7+ (no Python 2<->3 crossing)17**Dependencies:** None for core; `plumbum` for zero-deploy; `pywin32` for `PipeStream` on Windows18**Repository:** https://github.com/tomerfiliba-org/rpyc1920## When to Use2122- Remote testing -- run tests centrally, operations happen on remote machines23- Administration -- control heterogeneous machines from one place using Python24- Remote hardware -- access `ctypes`, `/dev` files, drivers on remote machines transparently25- Parallel execution -- overcome GIL by distributing work across RPyC processes26- Distributed computation -- platform-agnostic foundation for clustering27- Remote services -- implement secure RPC services without heavyweight frameworks28- Monkey-patching -- replace local modules with remote ones to cross network boundaries2930## When NOT to Use3132- Need a REST/HTTP API (use Flask, FastAPI)33- Need language-agnostic RPC (use gRPC, Thrift)34- Need message queuing (use Celery, RabbitMQ)35- Untrusted clients over the Internet without SSL/SSH wrapping3637---3839## Which File Do I Need?4041**Reference files** (distilled, code-rich summaries):4243| I need to... | Read |44|-------------------------------------------------------------------------------------------------|-------------------------------|45| Classic mode -- `rpyc.classic.connect()`, `conn.modules`, `conn.teleport()`, tutorials 1/2/4 | `classic-and-tutorials.md` |46| Services -- `rpyc.Service`, `exposed_`, `ThreadedServer`, `rpyc.discover()`, tutorial 3 | `services-and-servers.md` |47| Async -- `rpyc.async_()`, `AsyncResult`, `rpyc.timed()`, `BgServingThread`, tutorial 5 | `async-and-events.md` |48| Security -- `SSLAuthenticator`, `rpyc.ssl_connect()`, `restricted()`, `DeployedServer` | `security-and-connections.md` |49| API -- `rpyc.connect()`, `Connection`, `Service`, `Netref`, factory functions, `classpartial()` | `api-reference.md` |50| Demos -- echo, chat, filemon, sharing, async_client, boilerplate patterns | `demos-and-patterns.md` |51| Config -- `protocol_config`, `rpyc_classic.py`, `rpyc_registry.py`, Wireshark debugging | `config-and-cli.md` |5253Try distilled references (above) first. Use upstream docs below only when more detail is needed.5455**Original upstream docs** (for additional detail beyond the reference files):5657| Topic | Key API / search terms | Read |58|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|59| Theory of operation | boxing by-value/by-reference, netref proxying, address space unification, symmetry | `docs/theory.md` |60| Classic mode | `rpyc.classic.connect()`, `conn.modules`, `conn.execute()`, `conn.builtin`, `rpyc_classic.py` | `docs/classic.md` |61| Services | `rpyc.Service`, `exposed_` prefix, `@rpyc.exposed`, `@rpyc.service`, `conn.root`, `on_connect()`, `on_disconnect()`, `ALIASES`, `VoidService` | `docs/services.md` |62| Servers & registry | `ThreadedServer`, `ForkingServer`, `ClassicService`, `rpyc_classic.py` flags (`-m`, `-p`, `--register`), `rpyc_registry.py` | `docs/servers.md` |63| Async & background | `rpyc.async_()`, `AsyncResult` (`.ready`, `.value`, `.wait()`, `.set_expiry()`, `.add_callback()`), `rpyc.timed()`, `BgServingThread` | `docs/async.md` |64| Security model | `restricted()`, `allow_public_attrs`, `_rpyc_getattr`, `_rpyc_setattr`, `_rpyc_delattr`, capability-based security | `docs/security.md` |65| SSL/TLS | `SSLAuthenticator`, `rpyc.ssl_connect()`, `keyfile`, `certfile`, certificate/key setup | `docs/secure-connection.md` |66| Zero-deploy (SSH) | `DeployedServer`, `MultiServerDeployment`, `SshMachine`, `.classic_connect()`, `.classic_connect_all()`, plumbum | `docs/zerodeploy.md` |67| How-to recipes | `redirected_stdio()`, `rpyc.classic.pm()`, stdio redirection, tunneling over bridges, monkey-patching | `docs/howto.md` |68| Advanced debugging | pyenv multi-version testing, Docker testing, Wireshark capture, `rpyc_classic.py --host` | `docs/advanced-debugging.md` |69| Tutorial 1: Classic | `rpyc.classic.connect()`, `conn.modules`, `conn.builtins`, `conn.namespace`, `conn.teleport()`, `conn.eval()`, `conn.execute()` | `tutorial/tut1.md` |70| Tutorial 2: Netrefs | netref, `isinstance()`, exception propagation, `import_custom_exceptions`, `OneShotServer`, `protocol_config=` | `tutorial/tut2.md` |71| Tutorial 3: Services | `rpyc.Service`, `ThreadedServer`, `OneShotServer`, `rpyc.discover()`, `rpyc.list_services()`, `rpyc.connect_by_service()`, `classpartial` | `tutorial/tut3.md` |72| Tutorial 4: Callbacks | callbacks as first-class objects, passing local functions to remote, symmetric protocol | `tutorial/tut4.md` |73| Tutorial 5: Async | `rpyc.async_()`, `AsyncResult` (`.error`), `BgServingThread`, `conn.poll_all()`, `conn.serve`, event producer/consumer | `tutorial/tut5.md` |74| Use cases | remote testing, administration, hardware access, GIL workaround, distributed computation, clustering | `docs/usecases.md` |75| Release process | `hatch build`, `hatch publish`, git tagging, PyPI, semantic versioning, CHANGELOG | `docs/rpyc-release-process.md` |76| Per-module API | `core.brine`, `core.protocol`, `core.netref`, `core.service`, `core.stream`, `utils.server`, `utils.registry`, `utils.authenticators`, `utils.factory`, `utils.classic`, `utils.zerodeploy` | `api/*.md` (11 files) |7778---7980## Quick Reference8182### Connect (Classic Mode)8384```python85import rpyc86conn = rpyc.classic.connect("hostname") # port 1881287conn.modules.os.listdir("/tmp") # remote module access88conn.builtins.open("/etc/hostname").read() # remote builtins89```9091### Create a Service9293```python94import rpyc95from rpyc.utils.server import ThreadedServer9697class MyService(rpyc.Service):98 def on_connect(self, conn): pass99 def on_disconnect(self, conn): pass100 def exposed_add(self, a, b):101 return a + b102103ThreadedServer(MyService, port=18861).start()104```105106### Connect to a Service107108```python109conn = rpyc.connect("hostname", 18861)110conn.root.add(3, 4) # => 7111```112113For async, timed calls, BgServingThread examples see `async-and-events.md`.114For SSL, zero-deploy, service discovery examples see `security-and-connections.md` and `services-and-servers.md`.115116---117118## Common Mistakes119120| Mistake | Fix |121|----------------------------------------------------|--------------------------------------------------------------------------------------|122| `rpyc.async_(conn.root.fn)(args)` -- weak-ref lost | Store wrapper: `afn = rpyc.async_(conn.root.fn); afn(args)` |123| Expecting async execution order | No order guarantee for multiple async requests |124| `allow_all_attrs` on public server | Use `allow_exposed_attrs` (default) + capability-based access |125| No `BgServingThread` when using callbacks | Server callbacks won't process unless client serves requests |126| Overriding `__init__` on Service class | Use `on_connect(self, conn)` instead |127| Passing class instance vs class to ThreadedServer | `ThreadedServer(MyService)` = per-connection; `ThreadedServer(MyService())` = shared |128| Exposing objects with `sys` references | Attacker can traverse to `sys.modules`; use `restricted()` wrapper |129| Cross-Python-version connections (2<->3) | Not supported; 3.x<->3.y works if shared types/modules used |130| Not closing connections (resource leak) | Use `with rpyc.connect(...) as conn:` or try/finally with `conn.close()` |131132---133134## Key Concepts135136**Transparent** (remote objects behave local) | **Symmetric** (both ends serve requests) | **Boxing** (immutables by value, rest by reference as netrefs) | **Capability-based security** (pass specific objects, not broad access)137138---139> Converted and distributed by [TomeVault](https://tomevault.io/claim/bitranox) — claim your Tome and manage your conversions.140<!-- tomevault:4.0:skill_md:2026-04-14 -->