Skip to main content

a Python RPC framework using redis

Project description


Build Status codecov

PyEaseRPC is a Python RPC framework easy to use, which using Redis as backend.



from pyeasyrpc.rpc import remote_method
from pyeasyrpc.rpc import RPCService

class ServiceInstance(RPCService):
    def add(self, a, b):
        return a + b

    def sub(self, a, b):
        return a - b

    def make_dict(self, **kwargs):
        return dict(kwargs)

    def make_list(self, *args):
        return list(args)

def main():
    instance0 = ServiceInstance(process_request_in_thread=True)

    input("press any key to stop")


if __name__ == '__main__':


from pyeasyrpc.rpc import RPCClient

def main():
    client = RPCClient("ServiceInstance")
    print("method_list", client.get_methods())

    print("add", client.add(1, 2))
    print("sub", client.sub(100, 1.1))
    print("make_dict", client.make_dict(a=1, b=2, c=3))
    print("make_list", client.make_list(1, [2], {3}))

    except Exception as ex:
        print(type(ex), ex)

if __name__ == '__main__':

Async Client


import asyncio
from pyeasyrpc.rpc import AsyncRPCClient

def main():
    client = AsyncRPCClient("ServiceInstance")
    print("method_list", client.get_methods())

    async def add():
        print("add", await client.add(1, 2))

    async def sub():
        print("sub", await client.sub(100, 1.1))

    async def make_dict():
        print("make_dict", await client.make_dict(a=1, b=2, c=3))

    async def make_list():
        print("make_list", await client.make_list(1, [2], {3}))

    async def catch_exception():
            await client.add()
        except Exception as ex:
            print(type(ex), ex)

    async def func():
        task = [add(), sub(), make_list(), make_dict(), catch_exception()]
        # task.extend([add() for i in range(100)])
        # task.extend([sub() for i in range(100)])
        # task.extend([make_list() for i in range(100)])
        # task.extend([make_dict() for i in range(100)])
        # task.extend([catch_exception() for i in range(100)])
        await asyncio.wait(task)

    loop = asyncio.get_event_loop()

if __name__ == '__main__':

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

pyeasyrpc-0.0.1.tar.gz (15.0 kB view hashes)

Uploaded source

Built Distribution

pyeasyrpc-0.0.1-py3-none-any.whl (23.9 kB view hashes)

Uploaded py3

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