Skip to content

A naive async rpc framework based on redis, written in Python.

Notifications You must be signed in to change notification settings

LiangZuoting/aioredisrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

asyncredisrpc

A naive async rpc framework based on redis, written in Python.

asyncredisrpc is inspired by https://github.com/gowhari/pyredisrpc.

Installation

pip install asyncredisrpc

Usage

server

import asyncio
from asyncredisrpc.server import AsyncServer

queue_name = 'test_queue'
server = AsyncServer(queue_name, '172.21.16.114')


@server.task
async def sum(x, y):
    print('summing...')
    await asyncio.sleep(1)
    return x + y


if __name__ == '__main__':
    asyncio.run(server.run())

client

import asyncio
from asyncredisrpc.client import AsyncClient


async def main():
    queue_name = 'test_queue'
    client = AsyncClient(queue_name, '172.21.16.114')
    await client.connect()
    ret, data = await client.call('sum', 14, 3)
    print(f'get result: {ret} {data}')


if __name__ == '__main__':
    asyncio.get_event_loop().run_until_complete(main())

About

A naive async rpc framework based on redis, written in Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages