aiorpc package¶
Submodules¶
aiorpc.client module¶
-
class
aiorpc.client.RPCClient(host, port, *, timeout=3, loop=None, pack_encoding='utf-8', unpack_encoding='utf-8', pack_params=None, unpack_params=None)[source]¶ Bases:
objectRPC client.
- Usage:
>>> from aiorpc.client import RPCClient >>> client = RPCClient('127.0.0.1', 6000) >>> import asyncio >>> loop = asyncio.get_event_loop() >>> loop.run_until_complete(client.call('sum', 1, 2))
Parameters: - host (str) – Hostname.
- port (int) – Port number.
- timeout (int) – (optional) Socket timeout.
- pack_encoding (str) – (optional) Character encoding used to pack data using Messagepack.
- unpack_encoding (str) – (optional) Character encoding used to unpack data using Messagepack.
- pack_params (dict) – (optional) Parameters to pass to Messagepack Packer
- unpack_params (dict) – (optional) Parameters to pass to Messagepack Unpacker.
-
call(method, *args, _close=False)[source]¶ Calls a RPC method.
Parameters: - method (str) – Method name.
- args – Method arguments.
- _close – Close the connection at the end of the request. Defaults to false
aiorpc.connection module¶
aiorpc.constants module¶
aiorpc.exceptions module¶
aiorpc.log module¶
aiorpc.server module¶
-
aiorpc.server.register(name, f)[source]¶ Register a function on the RPC server. Usage:
>>> def sum(x, y): >>> return x + y >>> register('sum', sum)
Parameters: - name – The remote name of the function, can be different with the f.__name__.
- f – Function object. Must be a callable object or a coroutine object.
Returns: None
-
aiorpc.server.msgpack_init(**kwargs)[source]¶ Init parameters of msgpack packer and unpacker. Usage:
>>> msgpack_init(pack_encoding='utf-8')
Parameters: kwargs – See http://pythonhosted.org/msgpack-python/api.html default: pack_encoding=’utf-8’ pack_params=dict() unpack_encoding=’utf-8’ unpack_params=dict(use_list=False) Returns: None
-
aiorpc.server.set_timeout(timeout)[source]¶ Set the IO timeout Usage:
>>> set_timeout(1)
Parameters: timeout – Timeout. Seconds. Returns: None
Module contents¶
-
class
aiorpc.RPCClient(host, port, *, timeout=3, loop=None, pack_encoding='utf-8', unpack_encoding='utf-8', pack_params=None, unpack_params=None)[source]¶ Bases:
objectRPC client.
- Usage:
>>> from aiorpc.client import RPCClient >>> client = RPCClient('127.0.0.1', 6000) >>> import asyncio >>> loop = asyncio.get_event_loop() >>> loop.run_until_complete(client.call('sum', 1, 2))
Parameters: - host (str) – Hostname.
- port (int) – Port number.
- timeout (int) – (optional) Socket timeout.
- pack_encoding (str) – (optional) Character encoding used to pack data using Messagepack.
- unpack_encoding (str) – (optional) Character encoding used to unpack data using Messagepack.
- pack_params (dict) – (optional) Parameters to pass to Messagepack Packer
- unpack_params (dict) – (optional) Parameters to pass to Messagepack Unpacker.
-
call(method, *args, _close=False)[source]¶ Calls a RPC method.
Parameters: - method (str) – Method name.
- args – Method arguments.
- _close – Close the connection at the end of the request. Defaults to false
-
aiorpc.register(name, f)[source]¶ Register a function on the RPC server. Usage:
>>> def sum(x, y): >>> return x + y >>> register('sum', sum)
Parameters: - name – The remote name of the function, can be different with the f.__name__.
- f – Function object. Must be a callable object or a coroutine object.
Returns: None
-
aiorpc.msgpack_init(**kwargs)[source]¶ Init parameters of msgpack packer and unpacker. Usage:
>>> msgpack_init(pack_encoding='utf-8')
Parameters: kwargs – See http://pythonhosted.org/msgpack-python/api.html default: pack_encoding=’utf-8’ pack_params=dict() unpack_encoding=’utf-8’ unpack_params=dict(use_list=False) Returns: None