def __init__(self, conf, timeout):
self._conf = conf
self._timeout = timeout
self._unpacker = msgpack.Unpacker()
self._packer = msgpack.Packer()
# connection variables
self._peers = {} # peer_id -> Peer
self._sock_to_peer = {} # socket.connection -> Peer
self._peers_lock = threading.Lock() # for _peers and _sock_to_peers
# request / response variables
self._req_count = 0
self._req_count_lock = threading.Lock()
# For reuse of ValueEvent objects by a thread.
self._threadlocal = threading.local()
self._patch_client_for_gevent()
self._bg_thread = threading.Thread(
target=self._process_requests_in_background
)
self._bg_thread.setDaemon(True)
self._bg_thread.start()
评论列表
文章目录