Skip to main content

Python3 asyncio JSONRPC module

Project description

``aiojsonrpc2`` is a Python3 JSONRPC module built using ``asyncio``.

  • Supports Python 3.5+ only (uses async/await syntax)

  • Plain socket transport (not JSONRPC over HTTP)

  • Supports secure TLS (ie. SSL) sockets

This is a new, fast, and modern JSONRPC module originally built to support `aiostratum_proxy <https://github.com/wetblanketcc/aiostratum_proxy>`__ (a next-gen, extensible cryptocurrency mining proxy). However, releasing it as it’s own independent Python package made the most sense.

Installation

There are currently no external dependencies required for aiojsonrpc2, and installation is simple:

pip install aiojsonrpc2

Usage

To use aiojsonrpc2 and depending on your needs, you need to implement either a client or server ‘protocol’. Both ClientProtocol and ServerProtocol let you handle bi-directional JSONRPC communication.

All incoming JSONRPC requests infer a protocol instance method from the JSONRPC method parameter. For example, if the method contains client.show_message, then the protocol class implementation must have an instance method called handle_client_show_message:

from aiojsonrpc2 import ClientProtocol, ServerProtocol

class MyClientProtocol(ClientProtocol):
    # NOTE: the opposing connection (perhaps a server) would
    # have sent the `client.show_message` request;
    # bidirectional communication!
    def handle_client_show_message(self, connection, params, **kwargs):
        # assuming the message to show is `params[0]`
        print(params[0])

Note how all . (ie. full stops/periods) from the JSONRPC method parameter are replaced by _ (ie. underscore).

Future Considerations

Community involvement is appreciated. Code review, pull requests for bug fixes & improvements, reporting issues, spreading the word - all appreciated.

TODO:

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

aiojsonrpc2-1.0.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

aiojsonrpc2-1.0.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file aiojsonrpc2-1.0.0.tar.gz.

File metadata

  • Download URL: aiojsonrpc2-1.0.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiojsonrpc2-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0d5f892983b299ca7a79feeae6aa56cdd76370b590e00d6721519c0a9bae3a6d
MD5 8265e361a65122825f4882c443612ba0
BLAKE2b-256 c5690c87386c1d5b5e8bbd5c187ac14fcaf0f8827ad7b0c393301a1a83ea7d7b

See more details on using hashes here.

File details

Details for the file aiojsonrpc2-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiojsonrpc2-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e97d94deee4361e14f7d09f0c4273f32f2d4150efb1ce30b783e4f0f5478f7db
MD5 7f195fae44a8a7b0de37d0dd71405c38
BLAKE2b-256 f97f2d19422b4cd0bfa2cc86c84311255fc94a873570005f3559350f8a9f0dcc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page