def run(self):
        locs = self.locs
        sock = env.ctx.socket(zmq.REP)
        port = sock.bind_to_random_port("tcp://0.0.0.0")
        self.addr = "tcp://%s:%d" % (socket.gethostname(), port)
        logger.debug("TrackerServer started at %s", self.addr)
        def reply(msg):
            sock.send_pyobj(msg)
        while True:
            msg = sock.recv_pyobj()
            if isinstance(msg, SetValueMessage):
                self.set(msg.key, msg.value)
                reply('OK')
            elif isinstance(msg, AddItemMessage):
                self.add(msg.key, msg.item)
                reply('OK')
            elif isinstance(msg, RemoveItemMessage):
                self.remove(msg.key, msg.item)
                reply('OK')
            elif isinstance(msg, GetValueMessage):
                reply(self.get(msg.key))
            elif isinstance(msg, StopTrackerMessage):
                reply('OK')
                break
            else:
                logger.error("unexpected msg %s %s", msg, type(msg))
                reply('ERROR')
        sock.close()
        logger.debug("stop TrackerServer %s", self.addr)
dataset/ETHPy150Open douban/dpark/dpark/tracker.py/TrackerServer.run/original