zmq Poller

1.注册socket到poller中

poller = zmq.Poller()
poller.register(frontend, zmq.POLLIN) # receive worker message
poller.register(receiver, zmq.POLLIN) # put message to client

 

 

2.接受消息时依据socket标识来判断是该哪个socket接受消息

while True:
    if socks.get(frontend) == zmq.POLLIN:
        frontend.recv_multipart()

    if socks.get(receiver) == zmq.POLLIN:
        receiver.recv_multipart()

 

posted @ 2019-02-18 17:43  下路派出所  阅读(1223)  评论(0编辑  收藏  举报