or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication-and-security.mdclassic-mode.mdcli-tools.mdconnection-factory.mdindex.mdregistry-and-discovery.mdservers.mdservices-protocols.mdstreams-and-channels.mdutilities.md
tile.json

tessl/pypi-rpyc

Remote Python Call (RPyC) is a transparent and symmetric distributed computing library

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/rpyc@5.3.x

To install, run

npx @tessl/cli install tessl/pypi-rpyc@5.3.0

index.mddocs/

RPyC

Remote Python Call (RPyC) is a transparent and symmetric distributed computing library that enables distributed computing across processes and computers. It uses object-proxying techniques to leverage Python's dynamic nature, allowing remote objects to be manipulated as if they were local.

Package Information

  • Package Name: rpyc
  • Language: Python
  • Installation: pip install rpyc
  • Dependencies: plumbum

Core Imports

import rpyc

Common patterns for different use cases:

# For general connections
from rpyc import connect, connect_by_service, ssl_connect

# For classic mode
from rpyc import classic

# For services
from rpyc import Service, exposed

# For servers
from rpyc.utils.server import ThreadedServer, ThreadPoolServer, ForkingServer

# For registry and discovery
from rpyc.utils.registry import UDPRegistryServer, UDPRegistryClient

# For authentication
from rpyc.utils.authenticators import SSLAuthenticator

# For streams and channels
from rpyc.core import SocketStream, Channel

Basic Usage

Simple Connection

import rpyc

# Connect to an RPyC server
conn = rpyc.connect('hostname', 12345)

# Access remote objects through the root namespace
result = conn.root.some_remote_function('argument')

# Close the connection
conn.close()

Classic Mode

import rpyc

# Connect in classic mode for direct Python execution
conn = rpyc.classic.connect('hostname')

# Execute Python code remotely
conn.execute('x = 5 + 3')

# Evaluate expressions
result = conn.eval('x * 2')  # Returns 16

# Access remote modules
files = conn.modules.os.listdir('/tmp')

# Access remote builtins
remote_file = conn.builtin.open('/path/to/file', 'r')
content = remote_file.read()

conn.close()

Creating Services

import rpyc
from rpyc import exposed

class MyService(rpyc.Service):
    @exposed
    def get_data(self, key):
        return f"Data for {key}"
    
    @exposed
    def process_list(self, items):
        return [item.upper() for item in items]

# Run a server with the service
from rpyc.utils.server import ThreadedServer
server = ThreadedServer(MyService, port=12345)
server.start()

Architecture

RPyC's architecture is built around several key components:

  • Connection: Protocol-level communication channel with automatic object proxying
  • Services: Define what remote objects and methods are exposed across the connection
  • Netrefs: Transparent proxy objects that represent remote objects locally
  • Streams: Low-level transport mechanisms (TCP, SSL, pipes, SSH tunnels, etc.)
  • Servers: Multi-threaded, forking, or single-shot server implementations

The symmetric design means both sides of a connection can expose services to each other, enabling bidirectional remote procedure calls and distributed computing patterns.

Capabilities

Connection and Factory Functions

Core connection functionality including TCP, SSL, Unix socket, SSH tunnel, subprocess, and service discovery connections. These functions provide the primary ways to establish RPyC connections.

def connect(host, port, service=VoidService, config={}, ipv6=False, keepalive=False): ...
def ssl_connect(host, port, keyfile=None, certfile=None, ca_certs=None, **kwargs): ...
def connect_by_service(service_name, host=None, registrar=None, timeout=2, **kwargs): ...
def discover(service_name, host=None, registrar=None, timeout=2): ...

Connection and Factory Functions

Services and Protocols

Service classes for defining remote interfaces and protocol management for handling connections. Includes base service classes, specialized service types, and connection management.

class Service: ...
class VoidService(Service): ...
class SlaveService(Service): ...
class MasterService(Service): ...
class ClassicService(MasterService, SlaveService): ...
class Connection: ...

Services and Protocols

Classic Mode

Classic RPyC functionality providing direct remote Python execution, module access, and file transfer capabilities. This mode allows transparent remote code execution and filesystem operations.

def connect(host, port=18812, ipv6=False, keepalive=False): ...
def execute(code): ...
def eval(expression): ...
def upload(conn, localpath, remotepath, filter=None, **kwargs): ...
def download(conn, remotepath, localpath, filter=None, **kwargs): ...

Classic Mode

Server Implementations

Multi-threaded, forking, and specialized server implementations for hosting RPyC services. Includes configuration options for different deployment scenarios.

class ThreadedServer(Server): ...
class ThreadPoolServer(Server): ...
class ForkingServer(Server): ...
class OneShotServer(Server): ...

Server Implementations

Utilities and Helpers

Additional utilities including asynchronous operations, timeouts, background threads, decorators, and low-level helpers for advanced RPyC usage.

def async_(proxy): ...
def timed(timeout, func): ...
class BgServingThread: ...
def exposed(func): ...
def restricted(obj, attrs, wattrs=None): ...

Utilities and Helpers

Registry and Service Discovery

Service registry and discovery system for automatic service location and management. Enables services to advertise availability and clients to discover services by name.

class UDPRegistryServer: ...
class TCPRegistryServer: ...
class UDPRegistryClient: ...
class TCPRegistryClient: ...
def discover(service_name): ...
def list_services(): ...

Registry and Service Discovery

Authentication and Security

Authentication mechanisms and security features for securing RPyC connections and services. Includes SSL/TLS authentication, custom authenticators, and security configuration.

class SSLAuthenticator: ...
class Authenticator: ...
def create_secure_config(): ...
def restricted_service(): ...

Authentication and Security

CLI Tools

Command-line utilities for running RPyC servers and registries. Ready-to-use server implementations and registry services for deployment without custom code.

# Command-line tools:
# rpyc_classic [OPTIONS]     - Classic RPyC server
# rpyc_registry [OPTIONS]    - Registry server

# Server modes: stdio, threaded, forking, oneshot
# Registry modes: UDP, TCP

CLI Tools

Streams and Channels

Low-level transport mechanisms and communication channels for RPyC connections. Provides underlying transport layer for different communication methods.

class SocketStream: ...
class TunneledSocketStream: ...
class PipeStream: ...
class Channel: ...
class CompressedChannel: ...

Streams and Channels

Types

class BaseNetref:
    """Base class for network references (remote object proxies)"""

class AsyncResult:
    """Container for asynchronous operation results"""
    def ready(self) -> bool: ...
    def wait(self, timeout=None): ...
    def value(self): ...

class AsyncResultTimeout(Exception):
    """Raised when async operations timeout"""

class GenericException(Exception):
    """Wrapper for remote exceptions"""

# Stream and Channel classes
class SocketStream: ...
class TunneledSocketStream: ...  
class PipeStream: ...
class Channel: ...
class CompressedChannel: ...
class EncryptedChannel: ...

# Registry classes
class UDPRegistryServer: ...
class TCPRegistryServer: ...
class UDPRegistryClient: ...
class TCPRegistryClient: ...

# Authentication classes
class SSLAuthenticator: ...
class AuthenticationError(Exception): ...

# Configuration constants
DEFAULT_CONFIG: dict
SECURE_DEFAULT_CONFIG: dict
REGISTRY_PORT: int
DEFAULT_SSL_PORT: int