trio-jsonrpc

JSON-RPC v2.0 for Trio


License
MIT
Install
pip install trio-jsonrpc==0.4.0

Documentation

JSON-RPC v2.0 for Trio

PyPI Python Versions MIT License Build Status codecov Read the Docs

This project provides an implementation of JSON-RPC v 2.0 based on sansio-jsonrpc with all of the I/O implemented using the Trio asynchronous framework.

Quick Start

Install from PyPI:

$ pip install trio-jsonrpc

The following example shows a basic JSON-RPC client.

from trio_jsonrpc import open_jsonrpc_ws, JsonRpcException

async def main():
    async with open_jsonrpc_ws('ws://example.com/') as client:
        try:
            result = await client.request(
                method='open_vault_door',
                {'employee': 'Mark', 'pin': 1234}
            )
            print('vault open:', result['vault_open'])

            await client.notify(method='hello_world')
        except JsonRpcException as jre:
            print('RPC failed:', jre)

trio.run(main)

For more information, see the complete documentation.