예제 #1
0
    def _channel_dispatcher(self):
        while True:
            try:
                event = self._events.recv()
            except Exception as e:
                logger.error( \
                        'zerorpc.ChannelMultiplexer, ' + \
                        'ignoring error on recv: {0}'.format(e))
                continue
            channel_id = event.header.get('response_to', None)

            queue = None
            if channel_id is not None:
                channel = self._active_channels.get(channel_id, None)
                if channel is not None:
                    queue = channel._queue
            elif self._broadcast_queue is not None:
                queue = self._broadcast_queue

            if queue is None:
                logger.error( \
                        'zerorpc.ChannelMultiplexer, ' + \
                        'unable to route event: ' + \
                        event.__str__(ignore_args=True))
            else:
                queue.put(event)
예제 #2
0
    def _channel_dispatcher(self):
        while True:
            try:
                event = self._events.recv()
            except Exception as e:
                logger.error( \
                        'zerorpc.ChannelMultiplexer, ' + \
                        'ignoring error on recv: {0}'.format(e))
                continue
            channel_id = event.header.get('response_to', None)

            queue = None
            if channel_id is not None:
                channel = self._active_channels.get(channel_id, None)
                if channel is not None:
                    queue = channel._queue
            elif self._broadcast_queue is not None:
                queue = self._broadcast_queue

            if queue is None:
                logger.error( \
                        'zerorpc.ChannelMultiplexer, ' + \
                        'unable to route event: ' + \
                        event.__str__(ignore_args=True))
            else:
                queue.put(event)
예제 #3
0
    def _channel_dispatcher(self):  # channel 调度器, 给 给定的 channel 分发 event
        while True:
            try:
                event = self._events.recv()
            except Exception:
                logger.exception(
                    'zerorpc.ChannelMultiplexer ignoring error on recv')
                continue
            channel_id = event.header.get(
                u'response_to', None
            )  # 获取目标 ~~identity~~ zmq.ROUTER?  channel_id 是 message_id n122行

            queue = None
            if channel_id is not None:
                channel = self._active_channels.get(
                    channel_id, None
                )  # 根据 ~~identity~~ 获取 channel, channel_id 是 message_id n122行
                if channel is not None:
                    queue = channel._queue
            elif self._broadcast_queue is not None:  # 客户端来的第一个 event 包, 此时没有创建 channel,所以没有channel_id None
                queue = self._broadcast_queue

            if queue is None:
                logger.warning('zerorpc.ChannelMultiplexer,'
                               ' unable to route event: {0}'.format(
                                   event.__str__(ignore_args=True)))
            else:
                queue.put(event)
예제 #4
0
    def _channel_dispatcher(self):
        while True:
            event = self._events.recv()
            channel_id = event.header.get('response_to', None)

            queue = None
            if channel_id is not None:
                channel = self._active_channels.get(channel_id, None)
                if channel is not None:
                    queue = channel._queue
            elif self._broadcast_queue is not None:
                queue = self._broadcast_queue

            if queue is None:
                print >> sys.stderr, \
                        'zerorpc.ChannelMultiplexer, ', \
                        'unable to route event:', \
                        event.__str__(ignore_args=True)
            else:
                queue.put(event)
예제 #5
0
    def _channel_dispatcher(self):
        while True:
            event = self._events.recv()
            channel_id = event.header.get('response_to', None)

            queue = None
            if channel_id is not None:
                channel = self._active_channels.get(channel_id, None)
                if channel is not None:
                    queue = channel._queue
            elif self._broadcast_queue is not None:
                queue = self._broadcast_queue

            if queue is None:
                print >> sys.stderr, \
                        'zerorpc.ChannelMultiplexer, ', \
                        'unable to route event:', \
                        event.__str__(ignore_args=True)
            else:
                queue.put(event)