A Python gRPC wrapper for classes
Project description
🐍 Serpent-Serve
A lightweight gRPC-based library for remote method invocation and attribute access in Python.
✨ Features
- Remote Method Calls: Call methods on remote objects as if they were local
- Attribute Access: Get/set attributes on remote objects
- Dynamic Client: Automatically mirrors remote object's methods and attributes
- Error Handling: Propagates exceptions with full stack traces
🚀 Installation
pip install serpent-serve
🛠️ Usage
Server Side
from serpent_serve import SerpentServicer
class MyService:
def __init__(self):
value = 42
def greet(self, name):
return f"Hello, {name}!"
# Create gRPC server and add servicer
server = grpc.server(...)
serpent_servicer = SerpentServicer(MyService())
serpent_pb2_grpc.add_SerpentServicer_to_server(serpent_servicer, server)
Client Side
from serpent_serve import SerpentClient
channel = grpc.insecure_channel('localhost:50051')
client = SerpentClient(channel)
# Call remote methods
print(client.greet("World")) # "Hello, World!"
# Access remote attributes
print(client.value) # 42
client.value = 100
📚 API
Server
SerpentServicer(inner): Wraps your object to serve its methods/attributes
Client
SerpentClient(channel): Creates a client that mirrors the remote object- Automatically discovers all methods/attributes
- Provides transparent access via Python properties and methods
⚠️ Limitations
- Only JSON-serializable objects can be returned/set
- Methods must be callable with JSON-serializable arguments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
serpent_serve-0.1.1.tar.gz
(17.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file serpent_serve-0.1.1.tar.gz.
File metadata
- Download URL: serpent_serve-0.1.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
badb6031cfb3ff188c70387dd7d93b5929c612bf1d0b5e666ec9e2b9410056fa
|
|
| MD5 |
853d2b7afee65f66f552f57db555b473
|
|
| BLAKE2b-256 |
0e04b578d22844215ba8a8a519e87992fdd2bf7daffa1844cac2c4f34c4cb8db
|
File details
Details for the file serpent_serve-0.1.1-py3-none-any.whl.
File metadata
- Download URL: serpent_serve-0.1.1-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bebd37e0fb97f54af949eba7d336080b0c72a629aa5c86306cc576d9f503f00
|
|
| MD5 |
8bfc0fb203de23103a8a6d00930fbff2
|
|
| BLAKE2b-256 |
3f755b39a43fc389c441ea1894bb94b8510af1bd4275a91c77a38e2821b48f98
|