Skip to main content

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

  1. 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}!"
  1. 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
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smoothrpc-0.9.3.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smoothrpc-0.9.3-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

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

Hashes for smoothrpc-0.9.3.tar.gz
Algorithm Hash digest
SHA256 7141984b59dacc6ba4df45708eb8b3422966dab3d560108cbac84b6c666ce78b
MD5 7950b66b1e0ce06b41aff2d123d60e9a
BLAKE2b-256 e5a32eabcd3f8e698154e2600bd3aedc67cea7f67eb3fba1e1dfe94d648daf8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for smoothrpc-0.9.3.tar.gz:

Publisher: release.yml on weary/SmoothRPC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for smoothrpc-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c84d7bc0e5eba12311be2cb541af248121b9954e46bc7b76c630e9f93283ccf8
MD5 6dc51c2fca62557185d916b7c3133bfb
BLAKE2b-256 6a71a268fd26aed75fed4e21dcbde5c5238f32981c64fadae5ee2a770e281d22

See more details on using hashes here.

Provenance

The following attestation bundles were made for smoothrpc-0.9.3-py3-none-any.whl:

Publisher: release.yml on weary/SmoothRPC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page