SRPC is a lightweight Remote Procedure Call (RPC) library that provides a clean abstraction layer between distributed processes,
enabling rapid development and integration of distributed services.
- Simple API for exposing and calling remote procedures.
- Interface definition through Python conventions (no separate IDL required).
- Plug-and-play architecture — install and start implementing immediately.
- Remote exception propagation
- Serialization: Convert server-side exceptions.
- Rehydration: Raise equivalent exceptions on the client side.
- Stub generation for server and client.
- Live metrics dashboard, displaying call count and latency per procedure.
Strict naming conventions are required for the plug-and-play functionality.
- Download the latest release from the GitHub Releases page.
- Extract the archive
- Open the terminal inside
srpcLib-<version>directory. - To install the package run the command:
pip install .
Let’s build a simple distributed calculator service that supports the four basic arithmetic operators.
(Addition, Subtraction, Multiplication, Division)
project/
├─ calc/
│ ├─ __init__.py
│ ├─ calc_interface.py
│ ├─ calc.py
├─ srpc_calc_server_stub.py
├─ server.py
...
calcdirectory name, is the name of the package, that the server will servecalc_interface.pyis the service interfacecalc.pyis the service implementation
Both the service-package directory and the service-package.py file should have the same name.
I recommend only use lowercase for it.
We need to implement calc_interface.py, calc.py and server.py.
Copy the following code:
# calc_interface.py
from abc import ABC, abstractmethod
# The interface class name must be <package-name>Interface.
# The first character must be uppercase.
class CalcInterface(ABC):
@abstractmethod
def add(self, a: int, b: int) -> int:
pass
@abstractmethod
def sub(self, a: int, b: int) -> int:
pass
@abstractmethod
def mult(self, a: int, b: int) -> int:
pass
@abstractmethod
def div(self, a: int, b: int) -> int:
pass# calc.py
from .calc_interface import CalcInterface
# The service class name must be <package-name>.
# The first character must be uppercase.
class Calc(CalcInterface):
def add(self, a: int, b: int) -> int:
return a + b
def sub(self, a: int, b: int) -> int:
return a - b
def mult(self, a: int, b: int) -> int:
return a * b
def div(self, a: int, b: int) -> int:
return a / b# server.py
from srpc_calc_server_stub import SrpcCalcServerStub
calcServerStub = SrpcCalcServerStub()
calcServerStub.start()project/
├─ calc/
│ ├─ __init__.py
│ ├─ calc_interface.py
├─ srpc_calc_client_stub.py
├─ client.py
...
We need implement calc_interface.py and client.py.
Copy the following code:
# calc_interface.py
from abc import ABC, abstractmethod
# The interface class name must be <package-name>Interface.
# The first character must be in uppercase.
class CalcInterface(ABC):
@abstractmethod
def add(self, a: int, b: int) -> int:
pass
@abstractmethod
def sub(self, a: int, b: int) -> int:
pass
@abstractmethod
def mult(self, a: int, b: int) -> int:
pass
@abstractmethod
def div(self, a: int, b: int) -> int:
pass# client.py
from srpc_calc_client_stub import SrpcCalcClientStub
SERVER_HOST = "127.0.0.1" # You should use your LAN IP
calcStub = SrpcCalcClientStub(SERVER_HOST)
a = 4
b = 2
print(f"{calcStub.add(a, b)}")
print(f"{calcStub.mult(a, b)}")
print(f"{calcStub.sub(a, b)}")
print(f"{calcStub.div(a, b)}")The tool to generate the stubs is srpc_stub_gen.
Inside the server directory run the command:
python -m srpcLib.tools.srpc_stub_gen calc/calc_interface.py
This will generate two files srpc_calc_server_stub.py and srpc_calc_client_stub.py.
srpc_calc_server_stub.pyis the server-side stubsrpc_calc_client_stub.pyis the client-side stub
Move the srpc_calc_client_stub.py file to client directory.
The server uses 127.0.0.1 by default.
If your machine is connected to a LAN, it will automatically use your LAN IP address.
To check your IP address:
- Windows:
ipconfig - Linux:
ifconfig
Start the server:
Run this command inside the server directory:
python server.pyYou should see something like this:

Start the client:
Run this command inside the client directory:
python client.pyThe srpc_show_metrics allows you to see call count(sucess or fail) and latency per procedure, in real time.
To view it, run this command inside the server directory:
python -m srpcLib.tools.srpc_show_metrics srpc_server_metrics.logYou should see something like this:

In another terminal window, go inside the client directory and run the command: python client.py — two times.
Now back to srpc_show_metrics terminal window, you should see something like this:

In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure
to execute in a different address space of the current process (commonly on another computer on a shared computer network),
which is written as if it were a local procedure call, without the programmer explicitly writing the
details for the remote interaction. The programmer writes essentially the same code whether
the subroutine is local to the executing program, or remote.(Wikipedia contributors, 2025)
The diagram below illustrates the RPC flow between client and server:
+-----------------------------+ +------------------------------+
| CLIENT | | SERVER |
+-----------------------------+ +------------------------------+
| User Code | | |
| -------------------------> | 1. Call RPC stub with method + args |
| RPC Stub / Proxy | | |
| -------------------------> | 2. Prepare request object |
| Serializer (byte buffer) | | |
| -------------------------> | 3. Serialize method & args |
| Transport Layer (TCP/IP) | ---------> | 4. Receive request bytes |
| | | Transport Layer |
| | | --------------------------> |
| | | Deserialize request |
| | | Serializer |
| | | --------------------------> |
| | | Extract method + args |
| | | RPC Dispatcher |
| | | --------------------------> |
| | | Locate & invoke target fn |
| | | Target Function |
| | | --------------------------> |
| | | Return result |
| | | Serializer |
| <-------------------------- | <----------| Serialize return value |
| Deserializer | | |
| <-------------------------- | | |
| RPC Stub | | |
| Return result to user | | |
+-----------------------------+ +------------------------------+
With SRPC, you can rapidly configure and consume interface-oriented RPC services with minimal setup and native Python code.
WARNING: No performance tests or rigorous security analysis have been conducted. Do not use this in production environments.
Expansion Possibilities:
- Performance Benchmarking
- Security Review
- Authentication & Authorization Layers
For more details on the current project stage, read the last release notes, here: V0.0.0