

def read_frames(self):
    '\n        Read frames from the transport and process them. Some transports may\n        choose to do this in the background, in several threads, and so on.\n        '
    if (self._transport is None):
        return
    self._channels[0].send_heartbeat()
    data = self._transport.read(self._heartbeat)
    current_time = time.time()
    if (data is None):
        if (self._heartbeat and ((current_time - self._last_octet_time) > (2 * self._heartbeat))):
            msg = ('Heartbeats not received from %s for %d seconds' % (self._host, (2 * self._heartbeat)))
            self.transport_closed(msg=msg)
            raise ConnectionClosed(('Connection is closed: ' + msg))
        return
    self._last_octet_time = current_time
    reader = Reader(data)
    p_channels = set()
    try:
        for frame in Frame.read_frames(reader):
            if (self._debug > 1):
                self.logger.debug('READ: %s', frame)
            self._frames_read += 1
            ch = self.channel(frame.channel_id)
            ch.buffer_frame(frame)
            p_channels.add(ch)
    except Frame.FrameError as e:
        self.close(reply_code=501, reply_text=('frame error from %s : %s' % (self._host, str(e))), class_id=0, method_id=0, disconnect=True)
        raise ConnectionClosed(('connection is closed: %s : %s' % (self._close_info['reply_code'], self._close_info['reply_text'])))
    if (reader.tell() < len(data)):
        self._transport.buffer(data[reader.tell():])
    self._transport.process_channels(p_channels)

dataset/ETHPy150Open agoragames/haigha/haigha/connection.py Connection.read_frames/original