async4jsonrpc
This library is an asynchronous python library for the JSON-RPC specification.
It is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).
Installation
Install from PyPi via pip:
pip3 install async4jsonrpc
Features
- Compliant with the JSON-RPC 2.0 specification
- High performance by asyncio and coroutine
- Json serialization support via jsonpickle
Usage
Server Usage
from async4jsonrpc.server import JsonRpcServer
# create RPC json server
server = JsonRpcServer()
# registers a function to respond to RPC requests.
server.register_function(lambda x, y: x + y, 'add')
server.register_function(lambda x: x, 'ping')
# start to serve RPC request
server.serve('localhost', 8080)
Client Usage
import asyncio
from async4jsonrpc.client import JsonRpcClient
# create RPC json client
client = JsonRpcClient('127.0.0.1', 8080)
async def call_rpc(i):
# rpc: send rpc request
r = await client.ping(f'hello {i}')
print(r)
asyncio.run(call_rpc('shi'))
Json serialize
I use jsonpickle library for serialization and deserialization of complex Python objects to and from JSON
- Python object class example: thing.py
class Thing(object):
def __init__(self, name):
self.name = name
- Client call rpc with a python object: client-test.py
import asyncio
from async4jsonrpc.client import JsonRpcClient
from tests.thing import Thing
# create RPC json client
client = JsonRpcClient('127.0.0.1', 8080)
async def call_object_rpc():
obj = Thing('Awesome')
r = await client.ping(obj)
print(r)
asyncio.run(call_object_rpc())
TODO
- improve
Metadata
Release files for async4jsonrpc 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| async4jsonrpc-1.0.0.tar.gz | 10.6 kB | Without provenance | Details for async4jsonrpc-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| async4jsonrpc-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for async4jsonrpc-1.0.0-py3-none-any.whl |
Total release size: 22.9 kB
Release files / async4jsonrpc-1.0.0.tar.gz
| Download URL | async4jsonrpc-1.0.0.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8efc3479a2a3a08cd572595910732056ce82ea5337da0f6dc83d28efb5c2a08
|
|
BLAKE2b-256 checksum How to use checksums |
28b98beb88ee89fe32012e74eb1df8a45a82e23a4f250b2b03f51073d1e06436
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.12
|
Release files / async4jsonrpc-1.0.0-py3-none-any.whl
| Download URL | async4jsonrpc-1.0.0-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
895ed6b909674b03964f650f4b52d880ef90a7998417fa1c82aa227da51f7330
|
|
BLAKE2b-256 checksum How to use checksums |
c7e9175f8d02bdf4f2fddc1d6f4c4fc72da7adb00b3d694bc712d9d6d4e45d4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.12
|
Security for async4jsonrpc 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.