async def _test_call(): client = RPCClient(HOST, PORT) ret = await client.call('echo', 'message') eq_('message', ret) ret = await client.call('echo', 'message' * 100) eq_('message' * 100, ret) client.close()
async def _test_call_server_side_exception(): client = RPCClient(HOST, PORT) try: ret = await client.call('raise_error') except RPCError as e: eq_('error msg', str(e)) raise eq_('message', ret) client.close()
async def _test_call_server_side_exception(): client = RPCClient(path=PATH) try: ret = await client.call('raise_error') except EnhancedRPCError as e: client.close() eq_(e.parent, 'Exception') eq_('error msg', e.message) eq_('Exception: error msg', str(e)) raise RPCError eq_('message', ret)
from aiorpc import RPCClient import asyncio import uvloop async def do(cli): ret = await client.call('echo', 'message') print("{}\n".format(ret)) loop = uvloop.new_event_loop() asyncio.set_event_loop(loop) client = RPCClient('127.0.0.1', 6000) loop.run_until_complete(do(client)) client.close()
async def _test_call(): client = RPCClient(path=PATH) ret = await client.call('echo', 'message') eq_('message', ret) client.close()
async def _test_class_call(): client = RPCClient(HOST, PORT) ret = await client.call('my_class.echo', 'message') eq_('message', ret) client.close()
async def _test_call_socket_timeout(): client = RPCClient(path=PATH, timeout=1) await client.call('echo_delayed', 'message', 10) client.close()