A Python library for JSON-RPC 2.0
Project description
A Python library for JSON-RPC 2.0
This is a Specialized version of bsonrpc
aiobsonrpc
Support asyncio
Install
pip install aiobsonrpc
Example
echo server
import asyncio
import aiobsonrpc
@aiobsonrpc.service_class
class EchoService(object):
@aiobsonrpc.aio_rpc_request
async def echo(self, _, data):
await asyncio.sleep(1)
print(data)
return data
@asyncio.coroutine
async def on_connected(reader, writer):
aiobsonrpc.JSONRpc(reader, writer, services=EchoService())
loop = asyncio.get_event_loop()
server = asyncio.start_server(on_connected, '0.0.0.0', 6789, loop=loop)
loop.create_task(server)
loop.run_forever()
echo client
import asyncio
import aiobsonrpc
@asyncio.coroutine
async def do_connect():
reader, writer = await asyncio.open_connection('localhost', 6789, loop=loop)
rpc = aiobsonrpc.JSONRpc(reader, writer)
peer = rpc.get_peer_proxy(timeout=5)
res = await peer.echo(123)
print(res)
loop = asyncio.get_event_loop()
loop.run_until_complete(do_connect())
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
aiobsonrpc-0.0.2.tar.gz
(8.2 kB
view details)
Built Distribution
File details
Details for the file aiobsonrpc-0.0.2.tar.gz
.
File metadata
- Download URL: aiobsonrpc-0.0.2.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0923727d314550e81f84f7980493f61d4f9bd79c05ae2a3c7bb198244dd3c87c |
|
MD5 | 888ce72ef9061f4ec7bd5528682c16ff |
|
BLAKE2b-256 | 31a2cfd706d2263fa106ac9f733ef15694ecc5993361e8cbc534caca7887d124 |
Provenance
File details
Details for the file aiobsonrpc-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: aiobsonrpc-0.0.2-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f43054475cc31bd5f7e59a928c141b82889d89ee792b7823f2fc9ea6af0c89e |
|
MD5 | 808e6dcfba4e557941387e735234087b |
|
BLAKE2b-256 | 8e552a871af572730b38e085e3e446bd361af098dc271d458fb002e670e59e6f |