Skip to main content

A Lightweight RPC framework for Python

Project description

thinrpc: A Lightweight RPC Framework for Python

This library provides a base class and some decorators to make it easy to build distributed applications. RPC endpoints are defined as class methods and decorated with ```RpcModule.Method```, which registers the endpoint with the event-based RPC server dispatching requests to registered methods.

The ```RpcRemote``` class is an abstraction allowing applications to invoke methods on remote nodes using method call syntax. See the example below for an illustration!

Simple RPC server responding to invocations of the
'hello' method with a pleasant greeting
import sys

from thinrpc import RpcModule, RpcRemote, RpcApplication, OK

class FooNode(RpcApplication):

def __init__(self, port, name):
self.addr = ("localhost", port) = name

# Start the RPC server

def hello(self, sender):
return OK, "Hi, %s! It's %s" % (sender,

if __name__ == '__main__':
node = FooNode(9090, "Anson")

And now for a simple client script that invokes the ```hello``` method on the server application defined above.


import thinrpc
import sys

# Say hi to the server!
server = thinrpc.RpcRemote(("localhost", 9090))
#{'result': "Hi, ('', 49440)! It's Anson", 'err': False}

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

thinrpc-0.2.0.tar.gz (4.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page