'Try to consume data from the provided channel.
Keep in mind that data is only consumed if the channel is receive
ready.'

def _consume_data_from_channel(self, chan, recv_method, recv_ready_method):

    result = StringIO()
    result_bytes = bytearray()
    if recv_ready_method():
        data = recv_method(self.CHUNK_SIZE)
        result_bytes += b(data)
        while data:
            ready = recv_ready_method()
            if (not ready):
                break
            data = recv_method(self.CHUNK_SIZE)
            result_bytes += b(data)
    result.write(result_bytes.decode('utf-8'))
    return result
