qulab package¶
The best place to start is the examples folder before diving into the API.
qulab.dht package¶
This package is developed base on [kademlia](https://github.com/bmuller/kademlia)
Kademlia is a Python implementation of the Kademlia protocol which utilizes the asyncio library.
qulab.math package¶
qulab.storage module¶
qulab.exceptions module¶
-
exception
qulab.exceptions.
QuLabDHTMalformedMessage
[source]¶ Bases:
qulab.exceptions.QuLabException
Message does not contain what is expected.
-
exception
qulab.exceptions.
QuLabRPCError
[source]¶ Bases:
qulab.exceptions.QuLabException
RPC base exception.
-
exception
qulab.exceptions.
QuLabRPCServerError
[source]¶ Bases:
qulab.exceptions.QuLabRPCError
Server side error.
-
exception
qulab.exceptions.
QuLabRPCTimeout
[source]¶ Bases:
qulab.exceptions.QuLabRPCError
Timeout.
qulab.log module¶
-
class
qulab.log.
RedisHandler
(conn, channel='log')[source]¶ Bases:
qulab.log.BaseHandler
Publish log by redis
-
class
qulab.log.
ZMQHandler
(socket: zmq.sugar.socket.Socket)[source]¶ Bases:
qulab.log.BaseHandler
Publish log by zmq socket
qulab.rpc module¶
-
class
qulab.rpc.
RPCClientMixin
[source]¶ Bases:
qulab.rpc.RPCMixin
-
class
qulab.rpc.
RPCMixin
[source]¶ Bases:
abc.ABC
-
cancelPending
(addr, msgID, cancelRemote)[source]¶ Give up when request timeout and try to cancel remote task.
-
createPending
(addr, msgID, timeout=1, cancelRemote=True)[source]¶ Create a future for request, wait response before timeout.
-
handle
(source, data)[source]¶ Handle received data.
Should be called whenever received data from outside.
-
loop
¶ Event loop.
-
pending
¶
-
tasks
¶
-
-
class
qulab.rpc.
RPCServerMixin
[source]¶ Bases:
qulab.rpc.RPCMixin
-
executor
¶
-
-
class
qulab.rpc.
ZMQClient
(addr, timeout=1, loop=None)[source]¶ Bases:
qulab.rpc.RPCClientMixin
-
loop
¶ Event loop.
-
qulab.serialize module¶
-
qulab.serialize.
register
(cls: type, encode: Callable[[cls], bytes] = <built-in function dumps>, decode: Callable[[bytes], cls] = <built-in function loads>) → None[source]¶ Register a serializable type
- Parameters
cls – type
encode – Callable translate an object of type cls into bytes default: pickle.dumps
decode – Callable translate bytes to an object of type cls default: pickle.loads
qulab.utils module¶
-
qulab.utils.
IEEE_488_2_BinBlock
(datalist, dtype='int16', is_big_endian=True)[source]¶ 将一组数据打包成 IEEE 488.2 标准二进制块
- Parameters
datalist – 要打包的数字列表
dtype – 数据类型
endian – 字节序
- Returns
binblock, header 二进制块, 以及其 ‘header’
-
qulab.utils.
ShutdownBlocker
(title='Python script')¶
-
qulab.utils.
acceptArg
(f, name, keyword=True)[source]¶ Test if argument is acceptable by function.
- Parameters
f – callable function
name – str argument name
-
qulab.utils.
retry
(exception_to_check, tries=4, delay=0.5, backoff=2, logger=None)[source]¶ Retry calling the decorated function using an exponential backoff. :param exception_to_check: the exception to check.
may be a tuple of exceptions to check
- Parameters
tries (int) – number of times to try (not retry) before giving up
delay (float, int) – initial delay between retries in seconds
backoff (int) – backoff multiplier e.g. value of 2 will double the delay each retry
logger (logging.Logger) – logger to use. If None, print