Microlib for socket RPC
Project description
socket_rpc
socket_rpc
is a very simple microlib for remote procedure calls (RPC) over sockets in Python.
It exposes two functions:
rpc
- acts as a server for a Python RPCrpc_call
- allows you to call a function, registered on another host with therpc
decorator.
Install with:
pip install socket_rpc
Quick server example
To expose a function over TCP, just decorate it with the rpc
decorator:
import logging
import sys
import numpy as np
from socket_rpc import rpc
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
@rpc(host='localhost', port=61000, buffer_size=10 * 1024 * 1024)
def callback(np_arr: np.ndarray):
print(np_arr.shape)
Quick call example
To call a function already exposed with the rpc
decorator, just use the rpc_call
function:
import numpy as np
from socket_rpc import rpc_call
send_np_arr = rpc_call(host='localhost', port=61000)
send_np_arr(np.arange(1111))
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
socket_rpc-0.1.0.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for socket_rpc-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b2884e52445ebc2072ec1978d9f1cb184cc822bb51b701ca80cdfdd1f7526e0 |
|
MD5 | 73007189509fd66428bd55bc8a69e3a6 |
|
BLAKE2b-256 | 22042cf8db1af4d44e7487856e0f78f7436ff1b4f2bd3a64c141fd0e83b17c3f |