base.py 文件源码

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

项目:Round1 作者: general-ai-challenge 项目源码 文件源码
def __init__(self, cmd, port, address=None):
        try:
            import zmq
        except ImportError:
            raise ImportError("Must have zeromq for remote learner.")

        if address is None:
            address = '*'

        if port is None:
            port = 5556
        elif int(port) < 1 or int(port) > 65535:
            raise ValueError("Invalid port number: %s" % port)

        self.context = zmq.Context()
        self.socket = self.context.socket(zmq.PAIR)
        self.socket.bind("tcp://%s:%s" % (address, port))

        # launch learner
        if cmd is not None:
            subprocess.Popen((cmd + ' ' + str(port)).split())
        handshake_in = self.socket.recv().decode('utf-8')
        assert handshake_in == 'hello'  # handshake

    # send to learner, and get response;
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号