Name | SmoothRPC JSON |
Version |
0.9.3
JSON |
| download |
home_page | None |
Summary | Decorator-based RPC library based on asyncio. |
upload_time | 2024-12-08 13:56:59 |
maintainer | None |
docs_url | None |
author | weary |
requires_python | <4.0,>=3.11 |
license | None |
keywords |
asyncio
rpc
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
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
```bash
pip install --upgrade https://github.com/weary/SmoothRPC/tarball/master
```
## Quick Start
1. Define your RPC API class:
```python
from smooth_rpc import api
class APICommands:
@api()
async def say_hello(self, name:str) -> str:
return f"Hello, {name}!"
```
2. Set up the host:
```python
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
```
3. Create a client:
```python
# 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](https://github.com/weary/SmoothRPC/tree/main/example)
## License
SmoothRPC is released under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contact
For any questions or support, please open an issue on the [GitHub repository](https://github.com/weary/SmoothRPC/issues).
Raw data
{
"_id": null,
"home_page": null,
"name": "SmoothRPC",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "asyncio, rpc",
"author": "weary",
"author_email": "wearyspam@weary.nl",
"download_url": "https://files.pythonhosted.org/packages/e5/a3/2eabcd3f8e698154e2600bd3aedc67cea7f67eb3fba1e1dfe94d648daf8a/smoothrpc-0.9.3.tar.gz",
"platform": null,
"description": "Here's a README for the SmoothRPC project:\n\n# SmoothRPC\n\nDecorator-based RPC library based on asyncio.\n\nWorks by replacing all decorated functions with remote function calls. Arguments and results are pickle'd. Host exceptions are re-thrown client-side.\n\n> [!WARNING]\n> SmoothRPC uses pickle to serialize objects. Do not use in untrusted environments.\n\n## Installation\n\n```bash\npip install --upgrade https://github.com/weary/SmoothRPC/tarball/master\n```\n\n## Quick Start\n\n1. Define your RPC API class:\n\n```python\nfrom smooth_rpc import api\n\nclass APICommands:\n @api()\n async def say_hello(self, name:str) -> str:\n return f\"Hello, {name}!\"\n```\n\n2. Set up the host:\n\n```python\nfrom smooth_rpc import host_forever\n\n# instance of your own API class. Instance stays in-memory, so can be used for context.\napi_commands = APICommands()\n\n# bind-address, start with 'ipc' for unix sockets or 'tcp'\naddress = \"tcp://127.0.0.1:5000\"\n\n# SmoothRPC entrypoint:\n# - Find 'rpc'-decorated functions for use as RPC-endpoints.\n# - Listen on 'address', and keep handling RPC requests.\nawait host_forever(address, api_commands) # listen and handle RPC requests\n```\n\n3. Create a client:\n\n```python\n\n# instance of your own API class. Instance stays in-memory.\napi_commands = APICommands()\n\n# connect-address, same as host address\naddress = \"tcp://127.0.0.1:5000\"\n\n# SmoothRPC entrypoint:\n# - Replace all 'rpc'-decorated functions in 'api_commands' with remote function calls.\n# - Open connection to 'address'\nawait init_remote_rpc(address, api_commands)\n\n# Call the 'hello' function on the host, and store the result.\nout = await api_commands.hello(\"Alice\")\n\n# 'out' now has the value 'Hello Alice'\n```\n\n## Example\n\nA full example is available in the 'example' folder on [github](https://github.com/weary/SmoothRPC/tree/main/example)\n\n## License\n\nSmoothRPC is released under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contact\n\nFor any questions or support, please open an issue on the [GitHub repository](https://github.com/weary/SmoothRPC/issues).\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Decorator-based RPC library based on asyncio.",
"version": "0.9.3",
"project_urls": null,
"split_keywords": [
"asyncio",
" rpc"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6a71a268fd26aed75fed4e21dcbde5c5238f32981c64fadae5ee2a770e281d22",
"md5": "6dc51c2fca62557185d916b7c3133bfb",
"sha256": "c84d7bc0e5eba12311be2cb541af248121b9954e46bc7b76c630e9f93283ccf8"
},
"downloads": -1,
"filename": "smoothrpc-0.9.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6dc51c2fca62557185d916b7c3133bfb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 8491,
"upload_time": "2024-12-08T13:56:58",
"upload_time_iso_8601": "2024-12-08T13:56:58.532995Z",
"url": "https://files.pythonhosted.org/packages/6a/71/a268fd26aed75fed4e21dcbde5c5238f32981c64fadae5ee2a770e281d22/smoothrpc-0.9.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e5a32eabcd3f8e698154e2600bd3aedc67cea7f67eb3fba1e1dfe94d648daf8a",
"md5": "7950b66b1e0ce06b41aff2d123d60e9a",
"sha256": "7141984b59dacc6ba4df45708eb8b3422966dab3d560108cbac84b6c666ce78b"
},
"downloads": -1,
"filename": "smoothrpc-0.9.3.tar.gz",
"has_sig": false,
"md5_digest": "7950b66b1e0ce06b41aff2d123d60e9a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 7256,
"upload_time": "2024-12-08T13:56:59",
"upload_time_iso_8601": "2024-12-08T13:56:59.648968Z",
"url": "https://files.pythonhosted.org/packages/e5/a3/2eabcd3f8e698154e2600bd3aedc67cea7f67eb3fba1e1dfe94d648daf8a/smoothrpc-0.9.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-08 13:56:59",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "smoothrpc"
}