CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-rpyc

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

Pending
Overview
Eval results
Files

cli-tools.mddocs/

CLI Tools

Command-line utilities for running RPyC servers and registries. These tools provide ready-to-use server implementations and registry services that can be deployed without writing custom code.

Capabilities

RPyC Classic Server

Command-line classic RPyC server for remote Python execution and development.

# Command: rpyc_classic or rpyc_classic.py
# Usage: rpyc_classic [OPTIONS]

# Options:
--host HOST                    # Host to bind to (default: 0.0.0.0)
--port PORT                    # Port to bind to (default: 18812)
--ssl-port PORT               # SSL port to bind to (default: 18821)
--ssl-keyfile FILE            # SSL private key file
--ssl-certfile FILE           # SSL certificate file
--ssl-cafile FILE             # SSL CA certificate file
--mode {stdio,threaded,forking,oneshot}  # Server mode (default: threaded)
--host-only                   # Bind to host only (not 0.0.0.0)
--ipv6                        # Enable IPv6
--logfile FILE                # Log file path
--quiet                       # Quiet mode (less logging)
--register                    # Register with registry server
--registry-host HOST          # Registry server host
--registry-port PORT          # Registry server port
--registry-type {UDP,TCP}     # Registry type (default: UDP)
--auto-register              # Auto-register service

RPyC Registry Server

Command-line registry server for service discovery and management.

# Command: rpyc_registry or rpyc_registry.py  
# Usage: rpyc_registry [OPTIONS]

# Options:
--host HOST                   # Host to bind to (default: 0.0.0.0)
--port PORT                   # Port to bind to (default: 18811)
--mode {UDP,TCP}             # Registry mode (default: UDP)
--logfile FILE               # Log file path
--quiet                      # Quiet mode (less logging)
--pruning-timeout SECONDS    # Service pruning timeout (default: 3)
--allow-listing              # Allow service listing requests (default: True)

Server Modes

Different concurrency models available for the classic server.

# Server mode options:

STDIO_MODE = 'stdio'          # Single connection via stdin/stdout
THREADED_MODE = 'threaded'    # Multi-threaded server (default)
FORKING_MODE = 'forking'      # Multi-process forking server (Unix only)
ONESHOT_MODE = 'oneshot'      # Single connection server

Configuration Profiles

Pre-configured profiles for common deployment scenarios.

# Built-in configuration profiles:

DEVELOPMENT_PROFILE = {
    'host': 'localhost',
    'port': 18812,
    'mode': 'threaded',
    'logfile': None,
    'quiet': False,
    'ssl': False
}

PRODUCTION_PROFILE = {
    'host': '0.0.0.0', 
    'port': 18812,
    'mode': 'forking',
    'logfile': '/var/log/rpyc.log',
    'quiet': True,
    'ssl': True
}

SECURE_PROFILE = {
    'ssl': True,
    'ssl_port': 18821,
    'ssl_keyfile': '/etc/ssl/private/rpyc.key',
    'ssl_certfile': '/etc/ssl/certs/rpyc.crt',
    'host_only': True
}

Examples

Basic Classic Server

# Start basic classic server on default port
rpyc_classic

# Start on specific host and port
rpyc_classic --host 192.168.1.100 --port 12345

# Start with forking mode for better performance
rpyc_classic --mode forking

# Start with logging
rpyc_classic --logfile /var/log/rpyc.log

SSL Classic Server

# Start SSL server with certificates
rpyc_classic \
    --ssl-keyfile /path/to/server.key \
    --ssl-certfile /path/to/server.crt \
    --ssl-port 18821

# SSL server with client authentication
rpyc_classic \
    --ssl-keyfile server.key \
    --ssl-certfile server.crt \
    --ssl-cafile ca.crt \
    --ssl-port 18821

Classic Server with Registry

# Start server and register with local registry
rpyc_classic --register

# Register with specific registry server
rpyc_classic \
    --register \
    --registry-host registry.example.com \
    --registry-port 18811 \
    --registry-type TCP

# Auto-register with service name
rpyc_classic --auto-register

Registry Server

# Start UDP registry server (default)
rpyc_registry

# Start TCP registry server
rpyc_registry --mode TCP --port 18811

# Registry with custom settings
rpyc_registry \
    --host 0.0.0.0 \
    --port 18811 \
    --mode UDP \
    --pruning-timeout 5 \
    --logfile /var/log/rpyc-registry.log

Development Setup

# Terminal 1: Start registry
rpyc_registry --logfile registry.log

# Terminal 2: Start classic server with registry
rpyc_classic --register --logfile server.log

# Terminal 3: Connect with Python client
python3 -c "
import rpyc
conn = rpyc.classic.connect('localhost')
print('Connected to:', conn.modules.socket.gethostname())
conn.close()
"

Production Deployment

# Production registry server with TCP and logging
rpyc_registry \
    --mode TCP \
    --host 0.0.0.0 \
    --port 18811 \
    --logfile /var/log/rpyc-registry.log \
    --pruning-timeout 10

# Production classic server with SSL and forking
rpyc_classic \
    --mode forking \
    --host 0.0.0.0 \
    --port 18812 \
    --ssl-port 18821 \
    --ssl-keyfile /etc/ssl/private/rpyc.key \
    --ssl-certfile /etc/ssl/certs/rpyc.crt \
    --register \
    --registry-host localhost \
    --registry-type TCP \
    --logfile /var/log/rpyc-classic.log

Docker Deployment

# Docker run with classic server
docker run -d \
    --name rpyc-server \
    -p 18812:18812 \
    -v /path/to/certs:/certs:ro \
    python:3.9 \
    rpyc_classic \
        --host 0.0.0.0 \
        --port 18812 \
        --ssl-port 18821 \
        --ssl-keyfile /certs/server.key \
        --ssl-certfile /certs/server.crt

# Docker run with registry
docker run -d \
    --name rpyc-registry \
    -p 18811:18811/udp \
    python:3.9 \
    rpyc_registry \
        --host 0.0.0.0 \
        --port 18811 \
        --mode UDP

Systemd Service Configuration

# /etc/systemd/system/rpyc-classic.service
[Unit]
Description=RPyC Classic Server
After=network.target

[Service]
Type=simple
User=rpyc
Group=rpyc
ExecStart=/usr/local/bin/rpyc_classic \
    --mode forking \
    --host 0.0.0.0 \
    --port 18812 \
    --logfile /var/log/rpyc-classic.log \
    --register
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

# /etc/systemd/system/rpyc-registry.service  
[Unit]
Description=RPyC Registry Server
After=network.target

[Service]
Type=simple
User=rpyc
Group=rpyc
ExecStart=/usr/local/bin/rpyc_registry \
    --mode TCP \
    --host 0.0.0.0 \
    --port 18811 \
    --logfile /var/log/rpyc-registry.log
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

# Enable and start services
sudo systemctl enable rpyc-registry
sudo systemctl enable rpyc-classic
sudo systemctl start rpyc-registry
sudo systemctl start rpyc-classic

High Availability Setup

# Load balancer configuration (nginx)
# /etc/nginx/sites-available/rpyc
upstream rpyc_servers {
    server 192.168.1.10:18812;
    server 192.168.1.11:18812;
    server 192.168.1.12:18812;
}

server {
    listen 18812;
    proxy_pass rpyc_servers;
    proxy_timeout 30s;
    proxy_connect_timeout 5s;
}

# Multiple server instances
# Server 1:
rpyc_classic \
    --host 192.168.1.10 \
    --port 18812 \
    --mode forking \
    --register \
    --registry-host 192.168.1.100

# Server 2:
rpyc_classic \
    --host 192.168.1.11 \
    --port 18812 \
    --mode forking \
    --register \
    --registry-host 192.168.1.100

# Server 3:
rpyc_classic \
    --host 192.168.1.12 \
    --port 18812 \
    --mode forking \
    --register \
    --registry-host 192.168.1.100

# Registry cluster
rpyc_registry \
    --host 192.168.1.100 \
    --port 18811 \
    --mode TCP

SSL Certificate Management

# Generate self-signed certificates for development
openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

# Start server with generated certificates
rpyc_classic \
    --ssl-keyfile server.key \
    --ssl-certfile server.crt \
    --ssl-port 18821

# Use Let's Encrypt certificates for production
certbot certonly --standalone -d rpyc.yourdomain.com

rpyc_classic \
    --ssl-keyfile /etc/letsencrypt/live/rpyc.yourdomain.com/privkey.pem \
    --ssl-certfile /etc/letsencrypt/live/rpyc.yourdomain.com/fullchain.pem \
    --ssl-port 18821

Monitoring and Health Checks

# Health check script
#!/bin/bash
# rpyc-health-check.sh

HOST=${1:-localhost}
PORT=${2:-18812}

# Test connection
python3 -c "
import rpyc
import sys
try:
    conn = rpyc.connect('$HOST', $PORT, config={'sync_request_timeout': 5})
    conn.ping()
    conn.close()
    print('OK: RPyC server is responding')
    sys.exit(0)
except Exception as e:
    print(f'ERROR: {e}')
    sys.exit(1)
"

# Use with monitoring systems
# Nagios/Icinga check:
./rpyc-health-check.sh 192.168.1.10 18812

# Prometheus monitoring with custom exporter
rpyc_classic \
    --logfile /var/log/rpyc.log \
    --mode threaded &

# Parse logs for metrics
tail -f /var/log/rpyc.log | awk '
/connected/ { connections++ }
/disconnected/ { disconnections++ }
/error/ { errors++ }
{ print "rpyc_connections", connections }
{ print "rpyc_disconnections", disconnections }
{ print "rpyc_errors", errors }
'

Client Connection Examples

# Connect to CLI-started servers
import rpyc

# Connect to classic server
conn = rpyc.classic.connect('localhost', 18812)
print("Connected to:", conn.modules.socket.gethostname())

# Connect with SSL
ssl_conn = rpyc.classic.ssl_connect(
    'localhost', 18821,
    keyfile='client.key',
    certfile='client.crt'
)

# Discover via registry
services = rpyc.list_services()
print("Available services:", services)

# Connect by service name
service_conn = rpyc.connect_by_service('CLASSIC')

Environment Variables

# Environment variables supported by CLI tools:

RPYC_HOST = '0.0.0.0'                # Default host
RPYC_PORT = '18812'                  # Default port
RPYC_SSL_PORT = '18821'              # Default SSL port
RPYC_REGISTRY_HOST = 'localhost'     # Registry host
RPYC_REGISTRY_PORT = '18811'         # Registry port
RPYC_LOGFILE = '/var/log/rpyc.log'   # Log file path
RPYC_SSL_KEYFILE = 'server.key'      # SSL key file
RPYC_SSL_CERTFILE = 'server.crt'     # SSL certificate file

Exit Codes

# CLI tool exit codes:

SUCCESS = 0                          # Successful execution
INVALID_ARGS = 1                     # Invalid command line arguments
BIND_ERROR = 2                       # Failed to bind to port
SSL_ERROR = 3                        # SSL configuration error
REGISTRY_ERROR = 4                   # Registry connection error
PERMISSION_ERROR = 5                 # Insufficient permissions

Install with Tessl CLI

npx tessl i tessl/pypi-rpyc

docs

authentication-and-security.md

classic-mode.md

cli-tools.md

connection-factory.md

index.md

registry-and-discovery.md

servers.md

services-protocols.md

streams-and-channels.md

utilities.md

tile.json