用于异步的json-rpc客户端库
jsonrpc-async的Python项目详细描述
json rpc async:用于异步的紧凑型json-rpc客户端库图片::https://travis ci.org/armills/jsonrpc async.svg
:目标:https://travis ci.org/armills/jsonrpc async
…图片::https://coveralls.io/repos/armills/json rpc async/badge.svg
:目标:https://coveralls.io/r/armills/jsonrpc async
此代码派生自https://github.com/gciotta/jsonrpc requests
它发送到服务器构造函数。`(请参阅aiohttp文档。)<;https://aiohttp.readthedocs.io/en/stable/client謺reference.html謺aiohttp.clientsession>;``如果不传递给服务器,将自动创建clientsession对象。
执行远程json-rpc函数
。代码块::python
import asyncio
from jsonrpc_async import server
server=server('http://localhost:8080')
尝试:
await server.foo(1,2)
await server.foo(bar=1,baz=2)
await server.foo({foo':'bar})
awaitserver.foo.bar(baz=1,qux=2)
最后:
等待server.session.close()
asyncio.get_event_loop()。运行_直到完成(例程())
代码块::python
import asyncio
from jsonrpc_async import server
async def routine():
server=server('http://localhost:8080')
尝试:
await server.foo(bar=1,_ notification=true)
最后:
等待server.session.close()
asyncio.get_event_loop().run_until_complete(routine())
将参数传递给aiohttp(另请参阅“aiohttp文档”<;http://aiohttp.readthedocs.io/en/stable/client_reference.html;aiohttp.clientsession.request>;``uu)
代码块::python
import asyncio
import aiohttp
等待server.foo()
最后:
等待server.session.close()
asyncio.get_event_loop()。运行_直到完成(例程())
代码块::python
import asyncio
import aiohttp
from jsonrpc_async import server
async def routine():
server=server('http://unknown host')
尝试:
await server.foo()
传输错误除外:
打印(传输错误.args[1])#这将保存一个aiohttp异常实例
最后:
等待server.session.close()
asyncio.get_event_loop().run_直到完成(routine())
tests
----
安装python tox包并运行“tox”,我们将用不同版本的python来测试这个包。
changlog
-
-
1.1.0(2018年9月4日)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>-增加了对使用自定义json.loads方法`(1)<;https://github.com/armillls/jsonrpc async/pull/1>;`'@tdvis<;https://github.com/gitub.com/tdvis>;`````~~~~~~~~~>
<(8月23日,2018年)
~~~~~~~~~~~~~~~~
-将jsonrpc基础版本提升至1.0.2版
>1.0.0(2018年7月6日)
~~~~~~~~~~~~~~~
-将aiohttp最低版本提升至3.0.0版
-将jsonrpc基础版本提升至v版本1.0.1
credits
----
`@gciotta<;https://github.com/gciotta>;``用于创建基本项目'jsonrpc requests<;https://github.com/gciotta/jsonrpc requests>;`.
`@mbroadst<;https://github.com/mbroadst>;``用于提供嵌套方法调用的完全支持,json-rpc rfc
符合性和其他改进。
`@vaab<;https://github.com/vaab>;``用于提供api和测试改进,更好地符合rfc。
:目标:https://travis ci.org/armills/jsonrpc async
…图片::https://coveralls.io/repos/armills/json rpc async/badge.svg
:目标:https://coveralls.io/r/armills/jsonrpc async
此代码派生自https://github.com/gciotta/jsonrpc requests
它发送到服务器构造函数。`(请参阅aiohttp文档。)<;https://aiohttp.readthedocs.io/en/stable/client謺reference.html謺aiohttp.clientsession>;``如果不传递给服务器,将自动创建clientsession对象。
执行远程json-rpc函数
。代码块::python
import asyncio
from jsonrpc_async import server
尝试:
await server.foo(1,2)
await server.foo(bar=1,baz=2)
await server.foo({foo':'bar})
awaitserver.foo.bar(baz=1,qux=2)
最后:
等待server.session.close()
asyncio.get_event_loop()。运行_直到完成(例程())
代码块::python
import asyncio
from jsonrpc_async import server
async def routine():
server=server('http://localhost:8080')
尝试:
await server.foo(bar=1,_ notification=true)
最后:
等待server.session.close()
asyncio.get_event_loop().run_until_complete(routine())
将参数传递给aiohttp(另请参阅“aiohttp文档”<;http://aiohttp.readthedocs.io/en/stable/client_reference.html;aiohttp.clientsession.request>;``uu)
代码块::python
import asyncio
import aiohttp
等待server.foo()
最后:
等待server.session.close()
asyncio.get_event_loop()。运行_直到完成(例程())
代码块::python
import asyncio
import aiohttp
from jsonrpc_async import server
async def routine():
server=server('http://unknown host')
尝试:
await server.foo()
传输错误除外:
打印(传输错误.args[1])#这将保存一个aiohttp异常实例
最后:
等待server.session.close()
asyncio.get_event_loop().run_直到完成(routine())
tests
----
安装python tox包并运行“tox”,我们将用不同版本的python来测试这个包。
changlog
-
-
1.1.0(2018年9月4日)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>-增加了对使用自定义json.loads方法`(1)<;https://github.com/armillls/jsonrpc async/pull/1>;`'@tdvis<;https://github.com/gitub.com/tdvis>;`````~~~~~~~~~>
<(8月23日,2018年)
~~~~~~~~~~~~~~~~
-将jsonrpc基础版本提升至1.0.2版
>1.0.0(2018年7月6日)
~~~~~~~~~~~~~~~
-将aiohttp最低版本提升至3.0.0版
-将jsonrpc基础版本提升至v版本1.0.1
credits
----
`@gciotta<;https://github.com/gciotta>;``用于创建基本项目'jsonrpc requests<;https://github.com/gciotta/jsonrpc requests>;`.
`@mbroadst<;https://github.com/mbroadst>;``用于提供嵌套方法调用的完全支持,json-rpc rfc
符合性和其他改进。
`@vaab<;https://github.com/vaab>;``用于提供api和测试改进,更好地符合rfc。