Decorator-based RPC library based on asyncio.
Project description
Here's a README for the SmoothRPC project:
SmoothRPC
Decorator-based RPC library based on asyncio.
Works by replacing all decorated functions with remote function calls. Arguments and results are pickle'd. Host exceptions are re-thrown client-side.
[!WARNING] SmoothRPC uses pickle to serialize objects. Do not use in untrusted environments.
Installation
pip install --upgrade https://github.com/weary/SmoothRPC/tarball/master
Quick Start
- Define your RPC API class:
from smooth_rpc import api
class APICommands:
@api()
async def say_hello(self, name:str) -> str:
return f"Hello, {name}!"
- Set up the host:
from smooth_rpc import host_forever
# instance of your own API class. Instance stays in-memory, so can be used for context.
api_commands = APICommands()
# bind-address, start with 'ipc' for unix sockets or 'tcp'
address = "tcp://127.0.0.1:5000"
# SmoothRPC entrypoint:
# - Find 'rpc'-decorated functions for use as RPC-endpoints.
# - Listen on 'address', and keep handling RPC requests.
await host_forever(address, api_commands) # listen and handle RPC requests
- Create a client:
# instance of your own API class. Instance stays in-memory.
api_commands = APICommands()
# connect-address, same as host address
address = "tcp://127.0.0.1:5000"
# SmoothRPC entrypoint:
# - Replace all 'rpc'-decorated functions in 'api_commands' with remote function calls.
# - Open connection to 'address'
await init_remote_rpc(address, api_commands)
# Call the 'hello' function on the host, and store the result.
out = await api_commands.hello("Alice")
# 'out' now has the value 'Hello Alice'
Example
A full example is available in the 'example' folder on github
License
SmoothRPC is released under the MIT License. See the LICENSE file for details.
Contact
For any questions or support, please open an issue on the GitHub repository.
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
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 smoothrpc-0.9.3.tar.gz.
File metadata
- Download URL: smoothrpc-0.9.3.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7141984b59dacc6ba4df45708eb8b3422966dab3d560108cbac84b6c666ce78b
|
|
| MD5 |
7950b66b1e0ce06b41aff2d123d60e9a
|
|
| BLAKE2b-256 |
e5a32eabcd3f8e698154e2600bd3aedc67cea7f67eb3fba1e1dfe94d648daf8a
|
Provenance
The following attestation bundles were made for smoothrpc-0.9.3.tar.gz:
Publisher:
release.yml on weary/SmoothRPC
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smoothrpc-0.9.3.tar.gz -
Subject digest:
7141984b59dacc6ba4df45708eb8b3422966dab3d560108cbac84b6c666ce78b - Sigstore transparency entry: 154049120
- Sigstore integration time:
-
Permalink:
weary/SmoothRPC@1529d6f33e76202cbe079543eb1a4bde0ea2b531 -
Branch / Tag:
refs/tags/v0.9.3 - Owner: https://github.com/weary
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1529d6f33e76202cbe079543eb1a4bde0ea2b531 -
Trigger Event:
push
-
Statement type:
File details
Details for the file smoothrpc-0.9.3-py3-none-any.whl.
File metadata
- Download URL: smoothrpc-0.9.3-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c84d7bc0e5eba12311be2cb541af248121b9954e46bc7b76c630e9f93283ccf8
|
|
| MD5 |
6dc51c2fca62557185d916b7c3133bfb
|
|
| BLAKE2b-256 |
6a71a268fd26aed75fed4e21dcbde5c5238f32981c64fadae5ee2a770e281d22
|
Provenance
The following attestation bundles were made for smoothrpc-0.9.3-py3-none-any.whl:
Publisher:
release.yml on weary/SmoothRPC
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smoothrpc-0.9.3-py3-none-any.whl -
Subject digest:
c84d7bc0e5eba12311be2cb541af248121b9954e46bc7b76c630e9f93283ccf8 - Sigstore transparency entry: 154049121
- Sigstore integration time:
-
Permalink:
weary/SmoothRPC@1529d6f33e76202cbe079543eb1a4bde0ea2b531 -
Branch / Tag:
refs/tags/v0.9.3 - Owner: https://github.com/weary
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1529d6f33e76202cbe079543eb1a4bde0ea2b531 -
Trigger Event:
push
-
Statement type: