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.0.tar.gz
(17.3 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.0.tar.gz.
File metadata
- Download URL: serpent_serve-0.1.0.tar.gz
- Upload date:
- Size: 17.3 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 |
a04134772f67813bd2d4a6d76ec4b0d6fb1c3e82bb086d666a0aa46087ba3e52
|
|
| MD5 |
58191de78c0ce8842e71885b17863b7a
|
|
| BLAKE2b-256 |
8a0cdb98d8613b5cc4238ba4ce6ad0a761ffc889293a1123c26c4cbe4052ba12
|
File details
Details for the file serpent_serve-0.1.0-py3-none-any.whl.
File metadata
- Download URL: serpent_serve-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.1 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 |
df24a91aae2cc417ffd54e70b2d6712444d4d72935caf36ed1b03a615383f68c
|
|
| MD5 |
c6cfd2a48031d89c82d7039c09004e23
|
|
| BLAKE2b-256 |
886efe2ebca8bd10b3c3dd34a9bfbef13ffb54cddcf5e6ef962a0df1ff441113
|