zmq.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:dauber 作者: OpenDataAnalytics 项目源码 文件源码
def _wait_for_goahead(self):
        control_socket = self.context.socket(zmq.REP)
        control_socket.bind(os.environ['DAUBER_CONTROL_SOCKET_URI'])

        poller = zmq.Poller()
        poller.register(control_socket)

        timeout = 500
        t_last = time.time()
        while (time.time() - t_last) < timeout:
            ready = dict(poller.poll(10))
            if ready.get(control_socket):
                control_socket.recv()

                control_socket.send(b'')

                break

            self.socket.send_multipart(['hello', b''])
            t_last = time.time()

        assert (time.time() - t_last) < timeout, \
            "Timed out before recieving a signal to continue"

        del control_socket
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号