示例#1
0
    def _process_send(self):
        '''
        :return: size of processed data
        '''
        # send packet
        try:
            packet = self.response_queue.get(timeout=.1)
        except Queue.Empty:
            packet = ''

        size = len(packet)

        while packet:
            logger.debug('{0}: send packet {1}'.format(
                repr(self), str(load_packet(packet))[:60]))
            try:
                n = self.connection().send(packet)
                packet = packet[n:]
            except IOError as e:
                logger.debug(
                    '{0}: send packet failed, {1}'
                    .format(repr(self), str(e)))
                self.stop()
                break
        return size
示例#2
0
    def _process_send(self):
        '''
        :return: size of processed data
        '''
        # send packet
        try:
            packet = self.response_queue.get(timeout=.1)
        except Queue.Empty:
            packet = ''

        while packet:
            logger.debug('{0}: send packet {1}'.format(
                repr(self),
                str(load_packet(packet))[:60]))
            try:
                n = self.connection().send(packet)
                packet = packet[n:]
            except IOError as e:
                logger.debug('{0}: send packet failed, {1}'.format(
                    repr(self), str(e)))
                self.stop()
                break
        if packet:
            return len(packet)
        else:
            return 0
示例#3
0
    def _process_recv(self):
        '''
        :return: size of processed data
        '''
        packet = ""
        while True:
            try:
                chunk = self.connection().recv(2048)
            except IOError:
                chunk = ''
            if not chunk:
                break
            packet += chunk

        if packet:
            logger.debug('{0}: received packet {1}'.format(
                repr(self), str(load_packet(packet))[:60]))
            self.wire.rcv_packet(self, packet)
        return len(packet)
示例#4
0
    def _process_recv(self):
        '''
        :return: size of processed data
        '''
        packet = ""
        while True:
            try:
                chunk = self.connection().recv(2048)
            except IOError:
                chunk = ''
            if not chunk:
                break
            packet += chunk

        if packet:
            logger.debug('{0}: received packet {1}'.format(
                repr(self),
                str(load_packet(packet))[:60]))
            self.wire.rcv_packet(self, packet)
        return len(packet)