device.py 文件源码

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

项目:napalm-logs 作者: napalm-automation 项目源码 文件源码
def _setup_ipc(self):
        '''
        Subscribe to the right topic
        in the device IPC and publish to the
        publisher proxy.
        '''
        self.ctx = zmq.Context()
        # subscribe to device IPC
        log.debug('Creating the dealer IPC for %s', self._name)
        self.sub = self.ctx.socket(zmq.DEALER)
        if six.PY2:
            self.sub.setsockopt(zmq.IDENTITY, self._name)
        elif six.PY3:
            self.sub.setsockopt(zmq.IDENTITY, bytes(self._name, 'utf-8'))
        try:
            self.sub.setsockopt(zmq.HWM, self.opts['hwm'])
            # zmq 2
        except AttributeError:
            # zmq 3
            self.sub.setsockopt(zmq.RCVHWM, self.opts['hwm'])
        # subscribe to the corresponding IPC pipe
        self.sub.connect(DEV_IPC_URL)
        # self.sub.setsockopt(zmq.SUBSCRIBE, '')
        # publish to the publisher IPC
        self.pub = self.ctx.socket(zmq.PUSH)
        self.pub.connect(PUB_IPC_URL)
        try:
            self.pub.setsockopt(zmq.HWM, self.opts['hwm'])
            # zmq 2
        except AttributeError:
            # zmq 3
            self.pub.setsockopt(zmq.SNDHWM, self.opts['hwm'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号